shallow copy fix from belal

develop
Petr Mrázek 2009-11-12 17:50:50 +00:00
parent 370655a516
commit 7ce31ae483
3 changed files with 127 additions and 10 deletions

@ -372,9 +372,10 @@ bool API::ReadStoneMatgloss(vector<t_matgloss> & stones)
int matgloss_colors = minfo->getOffset("matgloss_stone_color"); int matgloss_colors = minfo->getOffset("matgloss_stone_color");
DfVector p_matgloss = d->dm->readVector(matgloss_address + matgloss_offset, 4); DfVector p_matgloss = d->dm->readVector(matgloss_address + matgloss_offset, 4);
stones.clear(); int size = p_matgloss.getSize();
stones.resize(0);
for (uint32_t i = 0; i< p_matgloss.getSize();i++) stones.reserve(size);
for (uint32_t i = 0; i< size;i++)
{ {
uint32_t temp; uint32_t temp;
// read the matgloss pointer from the vector into temp // read the matgloss pointer from the vector into temp

@ -71,6 +71,7 @@ void Process::setMemFile(const string & memf)
*/ */
/*
//TODO: rewrite this. really. It's ugly as hell. //TODO: rewrite this. really. It's ugly as hell.
bool isStopped(pid_t pid) bool isStopped(pid_t pid)
{ {
@ -99,7 +100,7 @@ bool isStopped(pid_t pid)
cerr << "couldn't open file " << filename << "assuming process stopped" << endl; cerr << "couldn't open file " << filename << "assuming process stopped" << endl;
return true; return true;
} }
*/
bool Process::attach() bool Process::attach()
{ {
int status; int status;
@ -109,6 +110,7 @@ bool Process::attach()
{ {
return false; return false;
} }
/*
if(!isStopped(my_handle)) if(!isStopped(my_handle))
{ {
// kill (SIGSTOP) // kill (SIGSTOP)
@ -126,6 +128,7 @@ bool Process::attach()
//cout << "wait step" << endl; //cout << "wait step" << endl;
} }
} }
*/
//usleep(10000); //usleep(10000);
//cout << "Attach: after conditional stop" << endl; //cout << "Attach: after conditional stop" << endl;
// can we attach? // can we attach?
@ -138,7 +141,6 @@ bool Process::attach()
} }
//usleep(10000); //usleep(10000);
//cout << "Attach: after ptrace" << endl; //cout << "Attach: after ptrace" << endl;
/*
while(true) while(true)
{ {
// we wait on the pid // we wait on the pid
@ -156,8 +158,8 @@ bool Process::attach()
{ {
break; break;
} }
}*/ }
// cout << "Managed to attach to pid " << my_handle << endl; // cout << "Managed to attach to pid " << my_handle << endl;
int proc_pid_mem = open(memFile.c_str(),O_RDONLY); int proc_pid_mem = open(memFile.c_str(),O_RDONLY);
if(proc_pid_mem == -1) if(proc_pid_mem == -1)
@ -209,8 +211,8 @@ bool Process::detach()
g_pProcess = NULL; g_pProcess = NULL;
g_ProcessHandle = 0; g_ProcessHandle = 0;
// continue, wait for it to recover // continue, wait for it to recover
kill(my_handle,SIGCONT); // kill(my_handle,SIGCONT);
while (isStopped(my_handle)); // while (isStopped(my_handle));
//usleep(10000); //usleep(10000);
// we finish // we finish
return true; return true;

@ -384,6 +384,19 @@ struct t_labor
{ {
string name; string name;
uint8_t value; uint8_t value;
t_labor() {
value =0;
}
t_labor(const t_labor & b){
name=b.name;
value=b.value;
}
t_labor & operator=(const t_labor &b){
name=b.name;
value=b.value;
return *this;
}
}; };
struct t_skill struct t_skill
{ {
@ -391,6 +404,25 @@ struct t_skill
uint16_t id; uint16_t id;
uint32_t experience; uint32_t experience;
uint16_t rating; uint16_t rating;
t_skill(){
id=rating=0;
experience=0;
}
t_skill(const t_skill & b)
{
name=b.name;
id=b.id;
experience=b.experience;
rating=b.rating;
}
t_skill & operator=(const t_skill &b)
{
name=b.name;
id=b.id;
experience=b.experience;
rating=b.rating;
return *this;
}
}; };
struct t_trait struct t_trait
@ -398,6 +430,22 @@ struct t_trait
uint16_t value; uint16_t value;
string displayTxt; string displayTxt;
string name; string name;
t_trait(){
value=0;
}
t_trait(const t_trait &b)
{
name=b.name;
displayTxt=b.displayTxt;
value=b.value;
}
t_trait & operator=(const t_trait &b)
{
name=b.name;
displayTxt=b.displayTxt;
value=b.value;
return *this;
}
}; };
struct t_creature struct t_creature
@ -410,7 +458,7 @@ struct t_creature
t_creaturflags2 flags2; t_creaturflags2 flags2;
string first_name; string first_name;
string nick_name; string nick_name;
string last_name; //string last_name;
string trans_name; string trans_name;
string generic_name; string generic_name;
string generic_squad_name; string generic_squad_name;
@ -429,6 +477,72 @@ struct t_creature
vector <t_skill> skills; vector <t_skill> skills;
vector <t_trait> traits; vector <t_trait> traits;
vector <t_labor> labors; vector <t_labor> labors;
t_creature() {
x=y=z=0;
type=happiness=id=agility=strength=toughness=money=0;
squad_leader_id = -1;
sex=0;
}
t_creature(const t_creature & b)
{
x = b.x;
y = b.y;
z = b.z;
type = b.type;
flags1 = b.flags1;
flags2 = b.flags2;
first_name = b.first_name;
nick_name = b.nick_name;
//string last_name;
trans_name = b.trans_name;
generic_name = b.generic_name;
generic_squad_name = b.generic_squad_name;
trans_squad_name = b.trans_squad_name;
profession = b.profession;
custom_profession = b.custom_profession;
current_job = b.current_job;
happiness = b.happiness;
id = b.id;
agility = b.agility;
strength = b.strength;
toughness = b.toughness;
money = b.money;
squad_leader_id = b.squad_leader_id;
sex = b.sex;
skills = b.skills;
traits = b.traits;
labors = b.labors;
}
t_creature & operator=(const t_creature &b)
{
x = b.x;
y = b.y;
z = b.z;
type = b.type;
flags1 = b.flags1;
flags2 = b.flags2;
first_name = b.first_name;
nick_name = b.nick_name;
//string last_name;
trans_name = b.trans_name;
generic_name = b.generic_name;
generic_squad_name = b.generic_squad_name;
trans_squad_name = b.trans_squad_name;
profession = b.profession;
custom_profession = b.custom_profession;
current_job = b.current_job;
happiness = b.happiness;
id = b.id;
agility = b.agility;
strength = b.strength;
toughness = b.toughness;
money = b.money;
squad_leader_id = b.squad_leader_id;
sex = b.sex;
skills = b.skills;
traits = b.traits;
return *this;
}
}; };
// TODO: research this further? consult DF hacker wizards? // TODO: research this further? consult DF hacker wizards?