Realy Jack...
"it-and-yes-no-be"
Very Nice
std::string Mission::getDescription(Player* player)
{
std::string value;
player->getStorage(storageId, value);
if(state.size())
return parseStorages(state, value);
if(atoi(value.c_str()) >= endValue)
return parseStorages(states.rbegin()->second, value);
for(int32_t i = endValue; i >= startValue; --i)
{
player->getStorage(storageId, value);
if(atoi(value.c_str()) == i)
return parseStorages(states[i - startValue], value);
}
return "Couldn't retrieve any mission description, please report to a gamemaster.";
}
quests.cppwhen uncomment it got errors
Code:In member function 'std::string Mission::parseStorages(std::string, std::string)': 51 C:\Users\Venn\Desktop\trunk.r4086\quests.cpp 'player' was not declared in this scope 51 C:\Users\Venn\Desktop\trunk.r4086\quests.cpp *** [obj//quests.o] Error 1
std::string Mission::parseStorages(std::string state, std::string value[B][COLOR="red"], Player* player[/COLOR][/B])
{
std::string::size_type start, end;
while((start = state.find("|STORAGE:")) != std::string::npos)
{
if((end = state.find("|", start)) = std::string::npos)
continue;
std::string value, storage = state.substr(start, end - start);
player->getStorage(storage, value);
state.replace(start, end, value);
}
replaceString(state, "|STATE|", value);
return state;
}
std::string Mission::getDescription(Player* player)
{
std::string value;
player->getStorage(storageId, value);
if(state.size())
return parseStorages(state, value[B][COLOR="red"], player[/COLOR][/B]);
if(atoi(value.c_str()) >= endValue)
return parseStorages(states.rbegin()->second, value[B][COLOR="red"], player[/COLOR][/B]);
for(int32_t i = endValue; i >= startValue; --i)
{
player->getStorage(storageId, value);
if(atoi(value.c_str()) == i)
return parseStorages(states[i - startValue], value[B][COLOR="red"], player[/COLOR][/B]);
}
return "Couldn't retrieve any mission description, please report to a gamemaster.";
}
std::string parseStorages(std::string state, std::string value[B][COLOR="red"], Player* player[/COLOR][/B]);
<quest name="The Tomes of Knowledge Quest" startstorageid="36049" startstoragevalue="0" endvalue="1">
<mission name="Finding the Tomes of Knowledge" storageid="36049" startvalue="-1" endvalue="11">
<missionstate id="1" description="You have found one Tome of Knowledge."/>
<missionstate id="2" description="You have found two Tomes of Knowledge."/>
<missionstate id="3" description="You have found three Tomes of Knowledge."/>
<missionstate id="4" description="You have found four Tomes of Knowledge."/>
<missionstate id="5" description="You have found five Tomes of Knowledge."/>
<missionstate id="6" description="You have delivered |STORAGE:36069|/12 Tomes of Knowledge to Cael."/>
<missionstate id="7" description="You have found seven Tomes of Knowledge."/>
<missionstate id="8" description="You have found eight Tomes of Knowledge."/>
<missionstate id="9" description="You have found nine Tomes of Knowledge."/>
<missionstate id="10" description="You have found ten Tomes of Knowledge."/>
<missionstate id="11" description="You have found eleven Tomes of Knowledge."/>
<missionstate id="12" description="You have found twelve Tomes of Knowledge."/>
</mission>
<mission name="Delivering the Tomes of Knowledge to Cael" storageid="36069" startvalue="-1" endvalue="11">
<missionstate id="1" description="You have delivered one Tome of Knowledge."/>
<missionstate id="2" description="You have delivered two Tomes of Knowledge."/>
<missionstate id="3" description="You have delivered three Tomes of Knowledge."/>
<missionstate id="4" description="You have delivered four Tomes of Knowledge."/>
<missionstate id="5" description="You have found |STORAGE:36049|/12 Tomes of Knowledge."/>
<missionstate id="6" description="You have delivered six Tomes of Knowledge."/>
<missionstate id="7" description="You have delivered seven Tomes of Knowledge."/>
<missionstate id="8" description="You have delivered eight Tomes of Knowledge."/>
<missionstate id="9" description="You have delivered nine Tomes of Knowledge."/>
<missionstate id="10" description="You have delivered ten Tomes of Knowledge."/>
<missionstate id="11" description="You have delivered eleven Tomes of Knowledge."/>
<missionstate id="12" description="You have delivered twelve Tomes of Knowledge."/>
</mission>
</quest>
quests.cpp
Code:std::string Mission::parseStorages(std::string state, std::string value[B][COLOR="red"], Player* player[/COLOR][/B]) { std::string::size_type start, end; while((start = state.find("|STORAGE:")) != std::string::npos) { if((end = state.find("|", start)) = std::string::npos) continue; std::string value, storage = state.substr(start, end - start); player->getStorage(storage, value); state.replace(start, end, value); } replaceString(state, "|STATE|", value); return state; }
quests.hCode:std::string Mission::getDescription(Player* player) { std::string value; player->getStorage(storageId, value); if(state.size()) return parseStorages(state, value[B][COLOR="red"], player[/COLOR][/B]); if(atoi(value.c_str()) >= endValue) return parseStorages(states.rbegin()->second, value[B][COLOR="red"], player[/COLOR][/B]); for(int32_t i = endValue; i >= startValue; --i) { player->getStorage(storageId, value); if(atoi(value.c_str()) == i) return parseStorages(states[i - startValue], value[B][COLOR="red"], player[/COLOR][/B]); } return "Couldn't retrieve any mission description, please report to a gamemaster."; }
Code:std::string parseStorages(std::string state, std::string value[B][COLOR="red"], Player* player[/COLOR][/B]);
dankoo, change it like this;
put */ and */ on parsin storage and let it be like this
[cpp]/*
std::string Mission:arseStorages(std::string state, std::string value, Player* player)
{
std::string::size_type start, end;
while((start = state.find("|STORAGE:")) != std::string::npos)
{
if((end = state.find("|", start)) = std::string::npos)
continue;
std::string value, storage = state.substr(start, end - start);
player->getStorage(storage, value);
state.replace(start, end, value);
}
replaceString(state, "|STATE|", value);
return state;
}*/[/cpp]
now also go to quest.h and put // here
[cpp]
// std::string parseStorages(std::string state, std::string value, Player* player);
[/cpp]
PS. this will made this code to not be loaded, if you want you can exclude them too.. now get the working one..
change your get description to this:
(this code dont work on latest 0.4 cause getstorage are not reading the first var as int, its reading it as string, so when you use atoi to convert stg into int it returns console errors...
it should be like this.. player->getStorage(temp, temp);
[cpp]std::string Mission::getDescription(Player* player)
{
std::string value;
int32_t find_storage;
player->getStorage(storageId, value);
if(state.size())
{
std::string ret = state;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
if(atoi(value.c_str()) >= endValue)
{
std::string ret = states.rbegin()->second;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
for(int32_t i = endValue; i >= startValue; --i)
{
player->getStorage(storageId, value);
if(atoi(value.c_str()) != i)
continue;
std::string ret = states[i - startValue];
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
return "Couldn't retrieve any mission description, please report to a gamemaster.";
} [/cpp]
dankoo, change it like this;
put */ and */ on parsin storage and let it be like this
[cpp]/*
std::string Mission:arseStorages(std::string state, std::string value, Player* player)
{
std::string::size_type start, end;
while((start = state.find("|STORAGE:")) != std::string::npos)
{
if((end = state.find("|", start)) = std::string::npos)
continue;
std::string value, storage = state.substr(start, end - start);
player->getStorage(storage, value);
state.replace(start, end, value);
}
replaceString(state, "|STATE|", value);
return state;
}*/[/cpp]
now also go to quest.h and put // here
[cpp]
// std::string parseStorages(std::string state, std::string value, Player* player);
[/cpp]
PS. this will made this code to not be loaded, if you want you can exclude them too.. now get the working one..
change your get description to this:
(this code dont work on latest 0.4 cause getstorage are not reading the first var as int, its reading it as string, so when you use atoi to convert stg into int it returns console errors...
it should be like this.. player->getStorage(temp, temp);
[cpp]std::string Mission::getDescription(Player* player)
{
std::string value;
int32_t find_storage;
player->getStorage(storageId, value);
if(state.size())
{
std::string ret = state;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
if(atoi(value.c_str()) >= endValue)
{
std::string ret = states.rbegin()->second;
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
for(int32_t i = endValue; i >= startValue; --i)
{
player->getStorage(storageId, value);
if(atoi(value.c_str()) != i)
continue;
std::string ret = states[i - startValue];
while((find_storage=ret.find("|STORAGE:"))>-1)
{
int32_t parsing_storage = find_storage+9;
std::string temp;
while((int) ret[parsing_storage] != (int)'|')
{
temp += ret[parsing_storage];
parsing_storage++;
}
parsing_storage -=find_storage-1;
player->getStorage(temp, temp);
ret.replace(find_storage, parsing_storage, temp);
}
replaceString(ret, "|STATE|", value);
return ret;
}
return "Couldn't retrieve any mission description, please report to a gamemaster.";
} [/cpp]