1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
void find_new_players( string str , Raider* raider[], string fname){
/*----------------------------- PREPARATION: -------------------------------*/
MyString tmp(str); // convert string in to MyString
string player, buffer, tag_t, end_tag; // declare strings
end_tag = tmp.get_last_tag(); // find the last tag in str
int last_id = raider[last_raider_used]->id(); // Get the last used raider id
/*----------------------------- STARTS --------------------------------*/
while(tag_t != end_tag)
{
MyString* player_ptr; // pointers for substr
string name, race, guild, clss;
int sex, level;
tag_t = tmp.find_next_tag(tmp.t_start());//find <keyx> from
buffer = tmp.get_substr(tag_t); //get player data(between <keyx> and </keyx>
player_ptr = new MyString(buffer); //Make a new MyString
buffer = "";
buffer = player_ptr->get_substr("name");
if(buffer == ""){
cout << "\nERROR! <name> not found in player #" << last_id+1
<< "!!\nCheck " << fname;
name = "UNKNOWN";
}
else name = buffer;
buffer = "";
buffer = player_ptr->get_substr("race");
if(buffer == ""){
cout << "\nERROR! <race> not found in player #" << last_id+1
<< "!!\nCheck " << fname;
race = "UNKNOWN";
}
else race = buffer;
buffer = "";
buffer = player_ptr->get_substr("guild");
if(buffer == ""){
cout << "\nERROR! <guild> not found in player #" << last_id+1
<< "!!\nCheck " << fname;
guild = "";
}
else guild = buffer;
buffer = "";
buffer = player_ptr->get_substr("sex");
if(buffer == ""){
cout << "\nERROR! <sex> not found in player #" << last_id+1
<< "!!\nCheck " << fname;
sex = 0;
}
else sex = atoi(buffer.c_str());
buffer = "";
buffer = player_ptr->get_substr("class");
if(buffer == ""){
cout << "\nERROR! <class> not found in player #" << last_id+1
<< "!!\nCheck " << fname;
clss = "UNKNOWN";
}
else clss = buffer;
buffer = "";
buffer = player_ptr->get_substr("level");
if(buffer == ""){
cout << "\nERROR! <level> not found in player #" << last_id+1
<< "!!\nCheck " << fname;
level = 80;
}
else level = atoi(buffer.c_str());
delete player_ptr;
if(!string_compare( name, raider )){
last_id++;
raider[++last_raider_used] = new Raider(last_id, name, race,
guild, sex, clss, level,
0, 1);
};
tmp.goto_tag("/level");
tag_t = tmp.find_next_tag(1 + tmp.t_start()); // </level>
tag_t = tmp.find_next_tag(1 + tmp.t_start()); // </keyx<>
tag_t = "<"+tag_t+">";
};
};
|