void* checkIfClientIsConnected(void* clients_void){ CheckClient* cc = (CheckClient*) clients_void; ListClient* clients = cc->clients; while(true){ ItemList client = clients->firstItem; while(client != NULL){ ClientNetwork* cn = client->client; cn->nbTry++; if(cn->nbTry == NB_MAX_TRY){ printf("Client %s disconnected\n", cn->name); client = client->next; savePlayer(*getPlayerByName(cn->players, cn->name)); removeClient(clients, cn); removePlayerByName(cn->players, cn->name); } else{ #ifdef DEBUG //printf("nbTry : %d\n", cn->nbTry); #endif client = client->next; } } getFileFromMap(cc->map); sleep(1); } pthread_exit(NULL); }
void deletePlayer(char* name) { pthread_mutex_lock(&peer_array->lock); delete_i(peer_array, getPlayerByName(name)); pthread_mutex_unlock(&peer_array->lock); redraw(0); }
void GameSaveInstance::addArmiesAndPlayersToMap(World * map) { // Go through the map, assign players to countries they control and set the number of armies for (unsigned i = 0; i < countryInfos.size(); i++) { Country* country = map->getCountryFromName(countryInfos[i]->countryName.c_str()); if (country == NULL) { setError(true, "Could not find saved country on map"); return; } country->setControllingPlayer(getPlayerByName(countryInfos[i]->owningPlayer)); country->addArmies(countryInfos[i]->numArmies); } }