From: Luca P. <lpa...@us...> - 2003-01-20 22:31:46
|
Update of /cvsroot/planeshift/planeshift/src/server In directory sc8-pr-cvs1:/tmp/cvs-serv10078/server Modified Files: psdatabase.cpp Log Message: fixed ' chars in name of NPC loaded, added Escape function for csString Index: psdatabase.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/server/psdatabase.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** psdatabase.cpp 20 Jan 2003 21:12:16 -0000 1.80 --- psdatabase.cpp 20 Jan 2003 22:31:41 -0000 1.81 *************** *** 1288,1296 **** int result; result = mysql->Command("INSERT INTO players(name,race, created_date, " "object_player, alive_ind, " "npc_spawn_rule_id) " ! "VALUES ('%s', %d, Now(), -1, 'Y', 0)", ! npcinfo->GetName(), raceID ); --- 1288,1298 ---- int result; + csString * name = new csString(npcinfo->GetName()); + name = mysql->Escape(name); result = mysql->Command("INSERT INTO players(name,race, created_date, " "object_player, alive_ind, " "npc_spawn_rule_id) " ! "VALUES ('%s', %d, Now(), -1, 'Y', 0)", ! name->GetData(), raceID ); *************** *** 1316,1325 **** /// Insert into objects table csVector3 pos = npcinfo->GetPosition(); ! result = mysql->Command("INSERT INTO objects(objtype, " "locx, locy, locz, " "visible_ind, " "player_owner,sector) " ! "VALUES ('PLAYR', %f, %f, %f, 'Y', %d, '%s') ", ! pos.x, pos.y, pos.z, playerID, npcinfo->GetSector()); --- 1318,1327 ---- /// Insert into objects table csVector3 pos = npcinfo->GetPosition(); ! result = mysql->Command("INSERT INTO objects(objtype, name, " "locx, locy, locz, " "visible_ind, " "player_owner,sector) " ! "VALUES ('PLAYR', '%s', %f, %f, %f, 'Y', %d, '%s') ", ! name->GetData(), pos.x, pos.y, pos.z, playerID, npcinfo->GetSector()); *************** *** 1333,1342 **** /// Creates the npc's own knowledge area first int order = 1; ! mysql->Command("INSERT INTO npc_knowledge_areas(player_id, " "area, " "priority) " "VALUES (%d, '%s', '%d')", ! playerID, npcinfo->GetName(), order++ ); ! // Add in all the other knowledge areas for ( int area = 0; area < npcinfo->knowledgeAreas.Length(); area++ ) --- 1335,1350 ---- /// Creates the npc's own knowledge area first int order = 1; ! result = mysql->Command("INSERT INTO npc_knowledge_areas(player_id, " "area, " "priority) " "VALUES (%d, '%s', '%d')", ! playerID, name->GetData(), order++ ); ! ! if ( result != 1 ) ! { ! printf("ERROR: %s\n", mysql->GetLastError() ); ! printf("QUERY: %s\n", mysql->GetLastQuery() ); ! } ! // Add in all the other knowledge areas for ( int area = 0; area < npcinfo->knowledgeAreas.Length(); area++ ) *************** *** 1383,1387 **** temp->strlwr(); int trigid = InsertTrigger ( temp->GetData(), ! npcinfo->GetName(), responseID, priorID ); --- 1391,1395 ---- temp->strlwr(); int trigid = InsertTrigger ( temp->GetData(), ! name->GetData(), responseID, priorID ); |