Merge branch 'master' into StringFormatting.

Cleaned up the problems. Tested on Linux. Still need to test on windows.

Conflicts:
	common/CMakeLists.txt
	common/MiscFunctions.cpp
	common/MiscFunctions.h
	common/debug.cpp
	world/Adventure.cpp
This commit is contained in:
Arthur Ice
2013-05-19 18:56:21 -07:00
618 changed files with 38225 additions and 38967 deletions
+46 -46
View File
@@ -92,10 +92,10 @@ int calc(string calc)
string integer1;
char op = 0;
int returnvalue = 0;
while (*iterator) {
char ch = *iterator;
if(ch >= '0' && ch <= '9') { //If this character is numeric add it to the buffer
buffer += ch;
}
@@ -109,7 +109,7 @@ int calc(string calc)
printf("Parser::calc() Error in syntax: '%s'.\n", calc.c_str());
return 0;
}
//what was the previous op
switch(op)
{
@@ -135,7 +135,7 @@ int calc(string calc)
break;
}
};
op = ch; //save current operator and continue parsing
}
buffer=""; //clear buffer now that we're starting on a new number
@@ -294,7 +294,7 @@ int Parser::HasQuestFile(uint32 npcid)
int success=1;
if (qstID==-1)
success = LoadScript(npcid, zone->GetShortName());
if (!success)
if (!success)
return false;
return true;
@@ -309,7 +309,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
int success=1;
if (qstID==-1)
success = LoadScript(npcid, zone->GetShortName(),mob);
if (!success)
if (!success)
return;
else
qstID = GetNPCqstID(npcid);
@@ -324,7 +324,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
MYSQL_ROW row;
char tmpname[65];
int charid=0;
if (mob && mob->IsClient()) // some events like waypoint and spawn don't have a player involved
{
charid=mob->CastToClient()->CharacterID();
@@ -337,8 +337,8 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
AddVar("charid.g",itoa(charid));
database.RunQuery(query, MakeAnyLenString(&query,
"SELECT name,value FROM quest_globals WHERE (npcid=%i || npcid=0) && (charid=%i || charid=0) && (zoneid=%i || zoneid=0) && expdate >= unix_timestamp(now())",
database.RunQuery(query, MakeAnyLenString(&query,
"SELECT name,value FROM quest_globals WHERE (npcid=%i || npcid=0) && (charid=%i || charid=0) && (zoneid=%i || zoneid=0) && expdate >= unix_timestamp(now())",
npcmob->GetNPCTypeID(),charid,zone->GetZoneID()), errbuf, &result);
printf("%s\n",query);
printf("%s\n",errbuf);
@@ -350,7 +350,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
sprintf(tmpname,"%s.g",row[0]);
AddVar(tmpname, row[1]);
}
mysql_free_result(result);
mysql_free_result(result);
}
if (query)
{
@@ -368,7 +368,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
AddVar("signal.g",data);
}
uint8 fac = 0;
if (mob && mob->IsClient()) {
if (mob && mob->IsClient()) {
AddVar("uguild_id.g", itoa(mob->CastToClient()->GuildID()));
AddVar("uguildrank.g", itoa(mob->CastToClient()->GuildRank()));
}
@@ -376,7 +376,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
if (mob && npcmob && mob->IsClient() && npcmob->IsNPC()) {
Client* client = mob->CastToClient();
NPC* npc = npcmob->CastToNPC();
// Need to figure out why one of these casts would fail..
if (client && npc) {
fac = client->GetFactionLevel(client->GetID(), npcmob->GetID(), client->GetRace(), client->GetClass(), DEITY_AGNOSTIC, npc->GetPrimaryFaction(), npcmob);
@@ -496,7 +496,7 @@ void Parser::Event(QuestEventID event, uint32 npcid, const char * data, NPC* npc
DelChatAndItemVars(npcid);
}
Parser::Parser() : DEFAULT_QUEST_PREFIX("default") {
MainList.clear();
pNPCqstID = new int32[1];
@@ -757,7 +757,7 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
#if Parser_DEBUG>10
printf("After: %s\n", arglist[0]);
#endif
char command[256];
strncpy(command, o_command.c_str(), 255);
command[255] = 0;
@@ -767,8 +767,8 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
*cptr = *cptr + ('a' - 'A');
*cptr++;
}
if (!strcmp(command,"write")) {
quest_manager.write(arglist[0], arglist[1]);
}
@@ -777,11 +777,11 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
quest_manager.me(parms.c_str());
//end Myra
}
else if (!strcmp(command,"spawn") || !strcmp(command,"spawn2"))
else if (!strcmp(command,"spawn") || !strcmp(command,"spawn2"))
{
float hdng;
if (!strcmp(command,"spawn"))
if (!strcmp(command,"spawn"))
{
hdng=mob->CastToClient()->GetHeading();
}
@@ -792,9 +792,9 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
quest_manager.spawn2(atoi(arglist[0]), atoi(arglist[1]), 0,
atof(arglist[3]), atof(arglist[4]), atof(arglist[5]), hdng);
}
else if (!strcmp(command,"unique_spawn"))
else if (!strcmp(command,"unique_spawn"))
{
float hdng;
hdng=mob->CastToClient()->GetHeading();
quest_manager.unique_spawn(atoi(arglist[0]), atoi(arglist[1]), 0,
@@ -878,18 +878,18 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
else if (!strcmp(command,"snow")) {
quest_manager.snow(atoi(arglist[0]));
}
else if (!strcmp(command,"surname")) {
else if (!strcmp(command,"surname")) {
quest_manager.surname(arglist[0]);
}
else if (!strcmp(command,"permaclass")) {
}
else if (!strcmp(command,"permaclass")) {
quest_manager.permaclass(atoi(arglist[0]));
}
}
else if (!strcmp(command,"permarace")) {
quest_manager.permarace(atoi(arglist[0]));
}
}
else if (!strcmp(command,"permagender")) {
quest_manager.permagender(atoi(arglist[0]));
}
}
else if (!strcmp(command,"scribespells")) {
quest_manager.scribespells(atoi(arglist[0]));
}
@@ -905,8 +905,8 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
else if (!strcmp(command,"movepc")) {
quest_manager.movepc((atoi(arglist[0])),(atof(arglist[1])),(atof(arglist[2])),(atof(arglist[3])),(atof(arglist[4])));
}
else if (!strcmp(command,"gmmove")) {
quest_manager.gmmove(atof(arglist[0]), atof(arglist[1]), atof(arglist[2]));
else if (!strcmp(command,"gmmove")) {
quest_manager.gmmove(atof(arglist[0]), atof(arglist[1]), atof(arglist[2]));
}
else if (!strcmp(command,"movegrp")) {
quest_manager.movegrp((atoi(arglist[0])),(atof(arglist[1])),(atof(arglist[2])),(atof(arglist[3])));
@@ -947,7 +947,7 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
else if (!strcmp(command,"settime")) {
quest_manager.settime(atoi(arglist[0]), atoi(arglist[1]));
}
else if (!strcmp(command,"itemlink")) {
else if (!strcmp(command,"itemlink")) {
quest_manager.itemlink(atoi(arglist[0]));
}
else if (!strcmp(command,"signal")) {
@@ -1024,7 +1024,7 @@ void Parser::ExCommands(string o_command, string parms, int argnums, uint32 npci
else if (!strcmp(command,"clear_proximity")) {
quest_manager.clear_proximity();
}
else if (!strcmp(command,"respawn"))
else if (!strcmp(command,"respawn"))
{
quest_manager.respawn(atoi(arglist[0]), atoi(arglist[1]));
}
@@ -1103,7 +1103,7 @@ int Parser::LoadScript(int npcid, const char * zone, Mob* activater)
NewEventList->Event.push_back(event1);
}
if (bracket==-1)
{
{
if(activater && activater->IsClient())
activater->CastToClient()->Message(10,"Line: %d,File: %s | error C0006: syntax error : too many ')'s",line_num,filename.c_str());
return 0;
@@ -1329,13 +1329,13 @@ void Parser::HandleVars(string varname, string varparms, string& origstring, str
temp[0] = atoi(varparms.c_str());
Replace(origstring,format,temp);
}
//used_pawn - random implementation.
else if (!strcmp(strlwr((const char*)varname.c_str()),"random")) {
Replace(origstring,format,itoa(MakeRandomInt(0, varparms[0]-1)));
}
else if (!strcmp(strlwr((const char*)varname.c_str()),"asc")) {
Replace(origstring,format,itoa(varparms[0]));
}
//used_pawn - random implementation.
else if (!strcmp(strlwr((const char*)varname.c_str()),"random")) {
Replace(origstring,format,itoa(MakeRandomInt(0, varparms[0]-1)));
}
else if (!strcmp(strlwr((const char*)varname.c_str()),"asc")) {
Replace(origstring,format,itoa(varparms[0]));
}
else if (!strcmp(strlwr((const char*)varname.c_str()),"gettok")) {
Replace(origstring,format,gettok(arglist[0],arglist[1][0],atoi(arglist[2])));
}
@@ -1386,7 +1386,7 @@ void Parser::ParseVars(string& text, uint32 npcid, Mob* mob)
if (*iterator != '(' && *iterator != ')')
buffer+=*iterator;
}
else
else
{
buffer.replace(0,1,"",0);
HandleVars(buffer,"",text,buffer2,npcid,mob);
@@ -1424,7 +1424,7 @@ void Parser::ParseVars(string& text, uint32 npcid, Mob* mob)
}
}
}
/*
char * fixstring(char * string)
{
@@ -1568,14 +1568,14 @@ int Parser::ParseCommands(string text, int line, int justcheck, uint32 npcid, Mo
if (*iterator == '"' && !escape && !ignore)
if (quote)quote--;
else quote++;
if (*iterator == ',' && !ignore && !quote && !escape && paren)
argit++;
if (*iterator == '(' && !ignore && !quote && !escape)
{
paren++;
if (paren == 1)
if (paren == 1)
{
if (last_finished)
{
@@ -1599,7 +1599,7 @@ int Parser::ParseCommands(string text, int line, int justcheck, uint32 npcid, Mo
return 0;
}
}
}
}
else if (*iterator == ')' && !ignore && !quote && !escape)
{
paren--;
@@ -1619,7 +1619,7 @@ int Parser::ParseCommands(string text, int line, int justcheck, uint32 npcid, Mo
mob->CastToClient()->Message(10,"Line: %d,File: %s | error C0006: syntax error : too many ')'s",line,filename.c_str() );
return 0;
}
}
}
else if (*iterator == '{' && !escape)
{
bracket++;
@@ -1656,7 +1656,7 @@ int Parser::ParseCommands(string text, int line, int justcheck, uint32 npcid, Mo
else lastif=0;
lastif=0,last_finished=0,quote=0,escape=0,ignore=0,argnums=0,argit=1;
}
}
}
else if (*iterator == ';' && !escape && !ignore && !quote)
{
if (last_finished)