I have the following structure:
typedef struct _DynamicArray {
int *data = nullptr;
_DynamicArray *ptr_next = nullptr;
_DynamicArray *ptr_dim = nullptr;
} DynamicArray; // so that every matrix cell contains another matrix cell
And then the following recursive method:
void _BuildArray(std::string const& source, StringIterator& sit, DynamicArray *dArray, bool& error) {
if (!error) {
while (sit+1 < source.length()) {
++sit;
switch (source[sit]) {
case '[':
dArray->ptr_dim = new DynamicArray();
_BuildArray(source, sit, dArray->ptr_dim, error);
break;
case ']':
return;
case ',':
break;
case ' ':
break;
default:
std::string str;
while (std::isdigit(source[sit])) {
str.push_back(source[sit]);
++sit;
}
--sit;
if (str.empty()) {
error = true;
return;
}
else {
dArray->data = new int(stoi(str));
dArray->ptr_next = new DynamicArray();
dArray = dArray->ptr_next;
}
break;
}
}
}
}
And then if I pass "[[1], 2, [[3,4], 5], [[[]]], [[[6]]], 7, 8, []]" as a parameter, it builds the following flatten: "[1,2,6,7,8]" (instead of "[1,2,3,4,5,6,7,8]"). Why?
The calling snippet is this:
StringIterator sit = 0;
bool error = false;
this->dynArray = new DynamicArray();
_BuildArray(this->listString, sit, this->dynArray, error);
Once your recursive _BuildArray call returns, you don't advance dArray like you do in the default: case. Meaning the next [ you encounter will overwrite the results of the previous [.
This answer is just to clarify my comment, I was talking about a structure which utilizes C++ STL structures to avoid having to manually manage allocations and dynamic memory, something like:
class CellVisitor
{
public:
virtual accept(Cell* cell) = 0;
};
class Cell
{
public:
virtual void visit() = 0;
};
class ContainerCell : public Cell
{
private:
std::vector<std::unique_ptr<Cell>> cells;
public:
void addCell(...) { ... }
void visit(CellVisitor* visitor) override
{
visitor->accept(this);
for (auto& cell : cells)
cell->visit();
}
};
class IntegerCell : public Cell
{
private:
std::vector<int> data;
public:
void visit(CellVisitor* visitor) override
{
visitor->accept(this);
}
}
Related
I have a class called StateMachine, which controls all possible Entity States.
I then have a class called State which is a base class for unique Entity classes, e.g Attack State, Flee State.
When a new unique State is created (within the StateMachine), it passes in a StateMachine pointer, which will then be stored in the State base class, so that each unique State created can access its State Machine.
When I attempt to access the pointers members (using -> operator) it simple doesn't come up with any public methods, and I don't know why.
If anyone has any clue it would be greatly appreciated.
StateMachine.h
using STATE_PTR = std::shared_ptr<State>;
// Class to implement a finite state machine using the state desing pattern
class StateMachine
{
public:
StateMachine();
~StateMachine();
void OnEnter(STATE_NAME sn);
void OnExit();
void OnEvent(STATE_SYMBOL & ss);
void OnTick(float st);
void ChangeState(STATE_NAME const & sn);
void RegisterState(ENTITY_CLASS const & ec);
typedef std::map<STATE_NAME, STATE_PTR> STATE_REGISTRY;
private:
STATE_REGISTRY state_registry;
STATE_NAME current_state;
};
StateMachine.cpp
using namespace::std;
StateMachine::StateMachine()
: state_registry()
{
current_state = STATE_NAME::UNKNOWN;
}
StateMachine::~StateMachine()
{
state_registry.clear();
}
void StateMachine::OnEnter(STATE_NAME sn)
{
current_state = sn;
if (state_registry[current_state] != nullptr)
{
state_registry[current_state]->OnEnter();
}
}
void StateMachine::OnExit()
{
if (state_registry[current_state] != nullptr)
{
state_registry[current_state]->OnExit();
}
}
void StateMachine::OnTick(float st)
{
}
void StateMachine::OnEvent(STATE_SYMBOL & ss)
{
state_registry[current_state]->OnEvent(ss);
}
void StateMachine::RegisterState(ENTITY_CLASS const & ec)
{
switch (ec)
{
case ENTITY_CLASS::PLAYER_TANK :
state_registry.insert(std::make_pair(STATE_NAME::STATE_1, std::make_shared<PlayerTankState1>(this)));
state_registry.insert(std::make_pair(STATE_NAME::STATE_2, std::make_shared<PlayerTankState2>(this)));
break;
case ENTITY_CLASS::ENEMY_TANK :
state_registry.insert(std::make_pair(STATE_NAME::STATE_3, std::make_shared<EnemyTankState1>(this)));
state_registry.insert(std::make_pair(STATE_NAME::STATE_4, std::make_shared<EnemyTankState2>(this)));
state_registry.insert(std::make_pair(STATE_NAME::STATE_5, std::make_shared<EnemyTankState3>(this)));
break;
default:
break;
}
}
void StateMachine::ChangeState(STATE_NAME const & sn)
{
state_registry[current_state]->OnExit();
current_state = sn;
state_registry[current_state]->OnEnter();
}
State.h
class StateMachine; // Forward decloration of the StateMachine class
// Base class for all states of the game system
class State
{
protected:
State(StateMachine * p)
: mp_Owner(p)
{}
public:
virtual ~State() {}
virtual void OnEnter() = 0;
virtual void OnExit() = 0;
virtual void OnTick(float) = 0;
virtual void OnEvent(STATE_SYMBOL) = 0;
StateMachine * mp_Owner;
};
EnemyTankState.cpp (Unique State)
EnemyTankState1::EnemyTankState1(StateMachine * p)
: State(p)
{
}
EnemyTankState1::~EnemyTankState1()
{
}
void EnemyTankState1::OnEnter()
{
cout << "Hi From Enemy Tank: Partolling State" << endl;
}
void EnemyTankState1::OnExit()
{
cout << "Bye From Enemy Enemy Tank: Partolling State" << endl;
}
void EnemyTankState1::OnTick(float dt)
{
}
void EnemyTankState1::OnEvent(STATE_SYMBOL ss)
{
switch (ss)
{
// Takes Enemy Tank to Attacking State
case STATE_SYMBOL::SYMBOL_2 :
mp_Owner->
break;
}
}
Within the code sample above, the line mp_Owner-> is what is giving me grief, as it is not opening up a list of public methods as you would expect when using a class pointer.
Any help would be much appreciated. Sorry for the long chunks of code, I couldn't think of any other way of getting my problem across.
i'm creating a little xbox application and for the beginning it should detect what game is currently running and then bypass and/or launch a program. Since i recently learned polymorphism i thought i could implement it here to gain efficiency. Below is my code (not as efficient as i thought it would be):
DWORD(__cdecl *XamGetCurrentTitleID)() = (DWORD(__cdecl *)())ResolveFunction("xam.xex", 0x1CF); // Resolves current Game ID
typedef enum _XBOX_GAMES : DWORD // Enum that holds Game IDs
{
BOOT_UP = 0x00000000,
DASHBOARD = 0xFFFE07D1,
FREESTYLEDASH = 0xF5D20000,
COD_WORLD_AT_WAR = 0x4156081C,
COD_MODERN_WARFARE = 0x415607E6,
COD_MODERN_WARFARE_2 = 0x41560817,
COD_BLACK_OPS_1 = 0x41560855,
COD_MODERN_WARFARE_3 = 0x415608CB,
COD_BLACK_OPS_2 = 0x415608C3,
COD_GHOSTS = 0x415608fC,
COD_ADVANCED_WARFARE = 0x41560914,
COD_BLACK_OPS_3 = 0x4156091D,
DESTINY = 0x415608F8,
GTAV = 0x545408A7
} XBOX_GAMES;
DWORD GameChecker()
{
DWORD lastID = NULL;
Game *game;
AW aw; BO1 bo1; BO2 bo2; BO3 bo3; Ghosts ghosts; MW2 mw2; MW3 mw3; Dashboard dashboard;
for (;;)
{
if (XamGetCurrentTitleID() != lastID)
{
switch (XamGetCurrentTitleID())
{
case BOOT_UP:
// nothing
break;
case DASHBOARD:
game = &dashboard;
game->Launch();
break;
case COD_MODERN_WARFARE_2:
game = &mw2;
game->Launch();
break;
case COD_MODERN_WARFARE_3:
game = &mw3;
game->Launch();
break;
case COD_GHOSTS:
game = &ghosts;
game->Bypass();
game->Launch();
break;
case COD_BLACK_OPS_1:
game = &bo1;
game->Launch();
break;
case COD_BLACK_OPS_2:
game = &bo2;
game->Bypass();
break;
case COD_BLACK_OPS_3:
game = &bo3;
game->Bypass();
break;
case COD_ADVANCED_WARFARE:
game = &aw;
game->Bypass();
game->Launch();
break;
}
lastID = XamGetCurrentTitleID();
}
}
return 0;
}
As you can see i could've moved the game->Launch() and game->Bypass() outside of the switch statement to have less code and only call it once, but i didn't knew how i could determine when a game needs a bypass and/or launch. This is my GameClass:
class Game
{
public:
virtual void Bypass() { }
virtual void Launch() { }
};
And this is the class of an example game:
// needs bypass and launch called
class AW : public Game
{
public:
void Bypass()
{
// bypass
}
void Launch()
{
Sleep(500);
XNotifyUI(L"AW - Loaded!");
}
};
I would like to know if there is a way to do something like this:
DWORD GameChecker()
{
DWORD lastID = NULL;
Game *game;
for (;;)
{
if (XamGetCurrentTitleID() != lastID)
{
switch (XamGetCurrentTitleID())
{
case BOOT_UP:
// nothing
break;
default:
game = &functionThatReturnsClassBasedOnGame(XamGetCurrentTitleID()); // I don't know how to code such an function
break;
}
if (game->needsBypass)
game->Bypass();
if (game->needsLaunch)
game->Launch();
lastID = XamGetCurrentTitleID();
}
}
return 0;
}
Any help is greatly appreciated! Thanks for your time.
A simple way to accomplish your example is like this:
const int NEEDS_BYPASS = 1;
const int NEEDS_LAUNCH = 2;
class Game
{
public:
virtual ~Game() { }
virtual int getFeatures() const { return 0; }
virtual void Bypass() { }
virtual void Launch() { }
};
class Game_Dashboard : public Game
{
public:
int getFeatures() const { return NEEDS_LAUNCH; }
void Launch() {
Sleep(500);
XNotifyUI(L"Dashboard - Loaded!");
}
};
class Game_ModernWarfare2 : public Game
{
public:
int getFeatures() const { return NEEDS_LAUNCH; }
void Launch() {
Sleep(500);
XNotifyUI(L"MW2 - Loaded!");
}
};
class Game_ModernWarfare3 : public Game
{
public:
int getFeatures() const { return NEEDS_LAUNCH; }
void Launch() {
Sleep(500);
XNotifyUI(L"MW3 - Loaded!");
}
};
class Game_Ghosts : public Game
{
public:
int getFeatures() const { return NEEDS_BYPASS | NEEDS_LAUNCH; }
void Bypass() {
// bypass...
}
void Launch() {
Sleep(500);
XNotifyUI(L"Ghosts - Loaded!");
}
};
class Game_BlackOpts1 : public Game
{
public:
int getFeatures() const { return NEEDS_LAUNCH; }
void Launch() {
Sleep(500);
XNotifyUI(L"BO1 - Loaded!");
}
};
class Game_BlackOpts2 : public Game
{
public:
int getFeatures() const { return NEEDS_BYPASS; }
void Bypass() {
// bypass...
}
};
class Game_BlackOpts3 : public Game
{
public:
int getFeatures() const { return NEEDS_BYPASS; }
void Bypass() {
// bypass...
}
};
class Game_AdvancedWarfare : public Game
{
public:
int getFeatures() const { return NEEDS_BYPASS | NEEDS_LAUNCH; }
void Bypass() {
// bypass
}
void Launch() {
Sleep(500);
XNotifyUI(L"AW - Loaded!");
}
};
Game* getGame(DWORD ID)
{
switch (ID)
{
case DASHBOARD:
return new Game_Dashboard;
case COD_MODERN_WARFARE_2:
return new Game_ModernWarfare2;
case COD_MODERN_WARFARE_3:
return new Game_ModernWarfare3;
case COD_GHOSTS:
return new Game_Ghosts;
case COD_BLACK_OPS_1:
return new Game_BlackOpts1;
case COD_BLACK_OPS_2:
return new Game_BlackOpts2;
case COD_BLACK_OPS_3:
return new Game_BlackOpts3;
case COD_ADVANCED_WARFARE:
return new Game_AdvancedWarfare;
}
return NULL;
}
DWORD GameChecker()
{
DWORD currentID, lastID = 0;
Game *game;
do
{
currentID = XamGetCurrentTitleID();
if (currentID != lastID)
{
lastID = currentID;
game = getGame(currentID);
if (game)
{
if (game->getFeatures() & NEEDS_BYPASS)
game->Bypass();
if (game->getFeatures() & NEEDS_LAUNCH)
game->Launch();
delete game;
}
}
}
while (true);
return 0;
}
However, a better use of polymorphism would to be more like this instead:
class Game
{
public:
virtual ~Game() { }
};
class CanBypass
{
public:
virtual void Bypass() = 0;
};
class CanLaunch
{
public:
virtual void Launch() = 0;
};
class Game_Dashboard : public Game, public CanLaunch
{
public:
void Launch() {
Sleep(500);
XNotifyUI(L"Dashboard - Loaded!");
}
};
class Game_ModernWarfare2 : public Game, public CanLaunch
{
public:
void Launch() {
Sleep(500);
XNotifyUI(L"MW2 - Loaded!");
}
};
class Game_ModernWarfare3 : public Game, public CanLaunch
{
public:
void Launch() {
Sleep(500);
XNotifyUI(L"MW3 - Loaded!");
}
};
class Game_Ghosts : public Game, public CanBypass, public CanLaunch
{
public:
void Bypass() {
// bypass...
}
void Launch() {
Sleep(500);
XNotifyUI(L"Ghosts - Loaded!");
}
};
class Game_BlackOpts1 : public Game, public CanLaunch
{
public:
void Launch() {
Sleep(500);
XNotifyUI(L"BO1 - Loaded!");
}
};
class Game_BlackOpts2 : public Game, public CanBypass
{
public:
void Bypass() {
// bypass...
}
};
class Game_BlackOpts3 : public Game, public CanBypass
{
public:
void Bypass() {
// bypass...
}
};
class Game_AdvancedWarfare : public Game, public CanBypass, public CanLaunch
{
public:
void Bypass() {
// bypass
}
void Launch() {
Sleep(500);
XNotifyUI(L"AW - Loaded!");
}
};
Game* getGame(DWORD ID)
{
switch (ID)
{
case DASHBOARD:
return new Game_Dashboard;
case COD_MODERN_WARFARE_2:
return new Game_ModernWarfare2;
case COD_MODERN_WARFARE_3:
return new Game_ModernWarfare3;
case COD_GHOSTS:
return new Game_Ghosts;
case COD_BLACK_OPS_1:
return new Game_BlackOpts1;
case COD_BLACK_OPS_2:
return new Game_BlackOpts2;
case COD_BLACK_OPS_3:
return new Game_BlackOpts3;
case COD_ADVANCED_WARFARE:
return new Game_AdvancedWarfare;
}
return NULL;
}
DWORD GameChecker()
{
DWORD currentID, lastID = 0;
Game *game;
CanBypass *bypasser;
CanLaunch *launcher;
do
{
currentID = XamGetCurrentTitleID();
if (currentID != lastID)
{
lastID = currentID;
game = getGame(currentID);
if (game)
{
bypasser = dynamic_cast<CanBypass*>(game);
if (bypasser)
bypasser->Bypass();
launcher = dynamic_cast<CanLaunch*>(game);
if (launcher)
launcher->Launch();
delete game;
}
}
}
while (true);
return 0;
}
In base class I have simple remove by id virtual function, however in derived class I need also emit a signal (notify) after removing.
In base class. Below is the default implementation of function
void Ui::GameEntityList::remove_games_by_sport_id_virt(const QString &sport_id)
{
for(QList<GameEntity*>::iterator it = m_game_list.begin();
it != m_game_list.end();)
{
GameEntity* tmp = (*it);
if(tmp->get_sport_id() == sport_id)
{
it = m_game_list.erase(it);
delete tmp;
tmp = 0;
}
else
{
++it;
}
}
}
In derived class. Overriding
void Ui::GameWidgetList::remove_games_by_sport_id_virt(const QString &id)
{
QList<GameEntity*>::iterator it;
for(it = m_game_list.begin(); it != m_game_list.end();)
{
GameWidget* tmp = dynamic_cast<GameWidget*>(*it);
Q_ASSERT(tmp != NULL);
if(tmp->get_sport_id() == id)
{
it = m_game_list.erase(it);
emit remove_game_in_monitor(tmp->get_id(), this->get_monitor_number()); // need to emit this signal
delete tmp;
tmp = 0;
}
else
{
++it;
}
}
this->set_number_of_games(m_game_list.size()); // need to call this function
}
I can't manage a way to avoid code duplication. Should I have an empty virtual notify() function and call it after removing an element? That way I can override notify() in derived to do the job. Is that an acceptable decision? Is implementing remove by id in base class unnecessary?
In your case, it is not that bad regarding amount of duplicated code. But, anyway, in situations like this, you may want to make this function non-virtual and move this customizable functionality to other virtual functions:
class GameEntityList
{
private:
virtual void on_erase(GameWidget* w)
{
//empty
}
virtual void on_finish(GameWidget* w)
{
//empty
}
//others
};
class GameWidgetList : public GameEntityList
{
private:
virtual void on_erase(GameWidget* w)
{
remove_game_in_monitor(w->get_id(), this->get_monitor_number());
}
virtual void on_finish(GameWidget* w)
{
this->set_number_of_games(m_game_list.size());
}
//others
};
And then:
void Ui::GameEntityList::remove_games_by_sport_id_virt(const QString &id)
{
QList<GameEntity*>::iterator it;
for(it = m_game_list.begin(); it != m_game_list.end();)
{
if(tmp->get_sport_id() == id)
{
it = m_game_list.erase(it);
this->on_erase(tmp); //customizable
delete tmp;
tmp = 0;
}
else
{
++it;
}
}
this->on_finish(); //customizable
}
I am trying to call a function which is located in the program from a DLL.
The program is closed source but the structures are know.
I need to call a function called "GetPlayerPosition" which looks like this:
// native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z)
static cell AMX_NATIVE_CALL n_GetPlayerPos(AMX *amx, cell *params)
{
CHECK_PARAMS(4);
CPlayer* pPlayer = pNetGame->GetPlayerPool()->GetAt((BYTE)params[1]);
if (pPlayer)
{
cell* cptr;
amx_GetAddr(amx, params[2], &cptr);
*cptr = amx_ftoc(pPlayer->m_vecPos.X);
amx_GetAddr(amx, params[3], &cptr);
*cptr = amx_ftoc(pPlayer->m_vecPos.Y);
amx_GetAddr(amx, params[4], &cptr);
*cptr = amx_ftoc(pPlayer->m_vecPos.Z);
return 1;
} else {
return 0;
}
}
I want to call this part from my DLL/SO:
pNetGame->GetPlayerPool()->GetAt((BYTE)<my own input data here>);
I know the streucture/classes are this:
typedef struct _VECTOR {
float X,Y,Z;
} VECTOR, *PVECTOR;
CNetGame *pNetGame = NULL;
class CNetGame
{
private:
CPlayerPool *m_pPlayerPool;
public:
CNetGame();
~CNetGame();
CPlayerPool * GetPlayerPool() { return m_pPlayerPool; };
};
void CNetGame::Init(BOOL bFirst = false)
{
// Setup player pool
if(!m_pPlayerPool) {
m_pPlayerPool = new CPlayerPool();
} else {
m_pPlayerPool->ResetPlayerScoresAndMoney();
}
}
class CPlayerPool
{
private:
BOOL m_bPlayerSlotState[MAX_PLAYERS];
CPlayer *m_pPlayers[MAX_PLAYERS];
public:
CPlayerPool();
~CPlayerPool();
BOOL New(BYTE bytePlayerID, PCHAR szPlayerName);
BOOL Delete(BYTE bytePlayerID, BYTE byteReason);
// Retrieve a player
CPlayer* GetAt(BYTE bytePlayerID) {
if (bytePlayerID >= MAX_PLAYERS) { return NULL; }
return m_pPlayers[bytePlayerID];
};
};
class CPlayer
{
private:
BYTE m_bytePlayerID;
public:
CPlayer();
~CPlayer() {};
VECTOR m_vecPos;
};
So how would I call pNetGame->GetPlayerPool()->GetAt((BYTE)<my own input data here>); with this setup?
I've got this here class defined in a header file:
class E_IndexList {
public:
E_UIntegerList* l;
inline void *data() { // retrieve packed data: stride depends on type (range)
return l->data();
}
inline void insert(unsigned value) {
if (value > maxval[l->range]) {
promote();
insert(value);
} else {
l->push_back(value);
}
}
inline size_t size() {
return l->size();
}
inline unsigned long get(int index) {
return l->get(index);
}
void promote() {
if (l->range == E_UIntegerList::e_byte) {
E_UShortList *new_short_list = new E_UShortList(*((E_UByteList*)l));
delete l;
l = new_short_list;
} else if (l->range == E_UIntegerList::e_short) {
E_UIntList *new_int_list = new E_UIntList(*((E_UShortList*)l));
delete l;
l = new_int_list;
} else ASSERT(false);
}
// start off with bytes by default
E_IndexList() {
l = new E_UByteList;
}
E_IndexList(E_UIntegerList::int_bits range) {
switch(range) {
case E_UIntegerList::e_byte:
l = new E_UByteList;
break;
case E_UIntegerList::e_short:
l = new E_UShortList;
break;
case E_UIntegerList::e_int:
l = new E_UIntList;
break;
default:
ASSERT(false);
break;
}
}
E_IndexList(const E_IndexList& cpy) { // copy ctor
switch(cpy.l->range) {
case E_UIntegerList::e_byte:
l = new E_UByteList(((E_UByteList*)cpy.l)->list);
break;
case E_UIntegerList::e_short:
l = new E_UShortList(((E_UShortList*)cpy.l)->list);
break;
case E_UIntegerList::e_int:
l = new E_UIntList(((E_UShortList*)cpy.l)->list);
break;
default:
ASSERT(false);
break;
}
}
~E_IndexList() {
delete l;
}
};
Here are some more classes it makes use of:
static const unsigned long maxval[] = {0xff,0xffff,0xffffffff};
class E_UIntegerList {
public:
enum int_bits {e_byte = 0, e_short = 1, e_int = 2};
virtual ~E_UIntegerList() {}
int_bits range;
virtual void push_back(int i) = 0;
virtual void *data() = 0;
virtual size_t size() = 0;
virtual unsigned long get(int index) = 0;
};
struct E_UByteList:public E_UIntegerList {
std::vector<unsigned char> list;
E_UByteList() {
range = e_byte;
}
E_UByteList(const std::vector<unsigned char>& copy) {
list = copy;
}
inline void push_back(int i) {
list.push_back(i);
}
inline void *data() { return list.data(); }
inline size_t size() { return list.size(); }
inline unsigned long get(int index) { return list[index]; }
};
struct E_UShortList:public E_UIntegerList {
std::vector<unsigned short> list;
E_UShortList() {
range = e_short;
}
E_UShortList(const std::vector<unsigned short>& copy) {
list = copy;
}
E_UShortList(const E_UByteList& promotee) {
range = e_short;
list.assign(promotee.list.begin(),promotee.list.end()); // assignment should be compatible
}
inline void push_back(int i) {
list.push_back(i);
}
inline void *data() { return list.data(); }
inline size_t size() { return list.size(); }
inline unsigned long get(int index) { return list[index]; }
};
struct E_UIntList:public E_UIntegerList {
std::vector<unsigned int> list;
E_UIntList() {
range = e_int;
}
E_UIntList(const std::vector<unsigned int>& copy) {
list = copy;
}
E_UIntList(const E_UShortList& promotee) {
range = e_int;
list.assign(promotee.list.begin(),promotee.list.end());
}
inline void push_back(int i) {
list.push_back(i);
}
inline void *data() { return list.data(); }
inline size_t size() { return list.size(); }
inline unsigned long get(int index) { return list[index]; }
};
Now the way that I use this class is I have a std::vector<E_IndexList> that I use as a container of index lists.
The strange behavior is that when I run the program sometimes it has no problems and sometimes it asserts false.
So this is a big red flag for me because something super fishy is going on. I will very likely end up abandoning the entire E_IndexList until I start working on game netcode which is a long ways off. But, I'd like to know what's going on here.
Every ctor I have sets the range to a valid value out of the enum in E_UIntegerList, so how could that assertion ever get tripped? And I can't begin to come up with an explanation of why the behavior is inconsistent. The test that calls this code is not multi-threaded.
Your E_UByteList from-vector constructor does not set the range value.
The entire design is a bit shoddy; you should learn how to use constructor initializer lists, and I would probably endow the base class with a protected constructor that sets the range value and which can be invoked from within the derived constructors' initializers.
You didn't define an assignment operator. See rule of three.
Your constructors such as this one:
E_UByteList(const std::vector<unsigned char>& copy) {
list = copy;
}
do not initialise range from the parent E_UIntegerList class.