Changeset 84754c0 in network-game for server/DataAccess.cpp
- Timestamp:
- Oct 17, 2014, 1:14:36 AM (10 years ago)
- Branches:
- master
- Children:
- c666518
- Parents:
- fb894b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/DataAccess.cpp
rfb894b4 r84754c0 72 72 } 73 73 74 // this is no longer used anywhere 75 int DataAccess::updatePlayer(string username, string password) 74 int DataAccess::updatePlayer(Player* p) 76 75 { 77 76 ostringstream values, where; 78 77 79 values << " password='" << password << "'";78 values << "level=" << p->level << ", experience=" << p->experience << ", honor=" << p->honor << ", wins=" << p->wins << ", losses=" << p->losses << ""; 80 79 81 where << " name='" << username << "'";80 where << "id=" << p->getId() << ""; 82 81 83 82 return update("users", values.str(), where.str()); … … 114 113 cout << "Class from db: " << atoi(row[3]) << endl; 115 114 } 115 p->level = atoi(row[4]); 116 p->experience = atoi(row[5]); 117 p->honor = atoi(row[6]); 118 p->wins = atoi(row[7]); 119 p->losses = atoi(row[8]); 116 120 cout << "Player class: " << p->playerClass << endl; 117 if (row[7] == NULL) 118 cout << "wins: NULL" << endl; 119 else 120 cout << "wins: " << atoi(row[7]) << endl; 121 if (row[8] == NULL) 122 cout << "losses: NULL" << endl; 123 else 124 cout << "losses: " << atoi(row[8]) << endl; 121 cout << "level: " << p->level << endl; 122 cout << "experience: " << p->experience << endl; 123 cout << "honor: " << p->honor << endl; 124 cout << "wins: " << p->wins << endl; 125 cout << "losses: " << p->losses << endl; 125 126 cout << "Loaded player from db" << endl; 126 127 }else { … … 140 141 list<Player*>* DataAccess::getPlayers() 141 142 { 143 // This method doesn't seem to ever get used. Decide whether it's actually needed 142 144 MYSQL_RES *result; 143 145 MYSQL_ROW row; … … 154 156 cout << row[0] << ", " << row[1] << ", " << row[2] << endl; 155 157 lstPlayers->push_back(new Player(row[1], row[2])); 158 159 // need to assign all the other db values to the player 156 160 } 157 161 … … 310 314 query_state = mysql_query(connection, oss.str().c_str()); 311 315 316 312 317 if (query_state != 0) { 313 318 cout << mysql_error(connection) << endl;
Note:
See TracChangeset
for help on using the changeset viewer.