Changeset 59061f6 in network-game for server/server.cpp


Ignore:
Timestamp:
Nov 27, 2012, 7:03:33 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
371ce29
Parents:
36082e8
Message:

Added new data access methods to save and retrieve player data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/server.cpp

    r36082e8 r59061f6  
    6363}
    6464
    65 // not sure if we actually need this function
    66 // when I made it, I thought we did
    6765Player *findPlayerByAddr(vector<Player> &vec, const sockaddr_in &addr)
    6866{
     
    10098      exit(1);
    10199   }
     100
     101   DataAccess da;
     102
     103   da.printPlayers();
     104
     105   da.insertPlayer("playerName3", "playerPass");
     106   cout << endl << "Inserted player" << endl << endl;
     107
     108   Player* p = da.getPlayer("playerName");
     109   cout << "player name: " << p->name << endl;
     110   delete(p);
     111
     112   p = da.getPlayer("playerName3");
     113   cout << "player name: " << p->name << endl;
     114   delete(p);
     115
     116   da.printPlayers();
     117   cout << endl;
    102118   
    103119   sock=socket(AF_INET, SOCK_DGRAM, 0);
     
    162178         if (p == NULL)
    163179         {
    164             vctPlayers.push_back(Player(username, from));
     180            Player newP(username, "");
     181            newP.setAddr(from);
     182
     183            vctPlayers.push_back(newP);
    165184            strcpy(serverMsg.buffer, "I'm thinking of a number between 1 and 1000. Guess what it is.");
    166185         }
Note: See TracChangeset for help on using the changeset viewer.