Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2009, 10:38:06 PM (15 years ago)
Author:
scheusso
Message:

first approach of having client-side pong physics
some optimisations in TrafficControl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp3/src/network/TrafficControl.cc

    r3015 r3043  
    142142    assert(clientListTemp_.find(clientID) != clientListTemp_.end() );
    143143    assert(clientListPerm_.find(clientID) != clientListPerm_.end() );
    144           assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
    145 
    146     for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++)
     144    assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() );
     145   
     146    // shortcut for maps
     147    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
     148    std::map<unsigned int, std::vector<obj> >& objectListTemp = clientListTemp_[clientID];
     149
     150    for(itvec = objectListTemp[gamestateID].begin(); itvec != objectListTemp[gamestateID].end(); itvec++)
    147151          {
    148       if(clientListPerm_[clientID].find((*itvec).objID) != clientListPerm_[clientID].end()) // check whether the obj already exists in our lists
    149       {
    150         clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
    151         clientListPerm_[clientID][(*itvec).objID].objValueSched = 0; //set scheduling value back
     152      if(objectListPerm.find((*itvec).objID) != objectListPerm.end()) // check whether the obj already exists in our lists
     153      {
     154        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
     155        objectListPerm[(*itvec).objID].objValueSched = 0; //set scheduling value back
    152156      }
    153157      else
    154158      {
    155159        assert(0);
    156         clientListPerm_[clientID][(*itvec).objID].objCurGS = gamestateID;
    157         clientListPerm_[clientID][(*itvec).objID].objID = (*itvec).objID;
    158         clientListPerm_[clientID][(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
    159         clientListPerm_[clientID][(*itvec).objID].objSize = (*itvec).objSize;
     160        objectListPerm[(*itvec).objID].objCurGS = gamestateID;
     161        objectListPerm[(*itvec).objID].objID = (*itvec).objID;
     162        objectListPerm[(*itvec).objID].objCreatorID = (*itvec).objCreatorID;
     163        objectListPerm[(*itvec).objID].objSize = (*itvec).objSize;
    160164      }
    161165          }
    162166           // remove temporary list (with acked objects) from the map
    163     clientListTemp_[clientID].erase( clientListTemp_[clientID].find(gamestateID) );
     167    objectListTemp.erase( objectListTemp.find(gamestateID) );
    164168        }
    165169
     
    227231    //if listToProcess contains new Objects, add them to clientListPerm
    228232    std::vector<obj>::iterator itvec;
     233   
     234    std::map<unsigned int, objInfo >& objectListPerm = clientListPerm_[clientID];
     235   
    229236          for( itvec=list.begin(); itvec != list.end(); itvec++)
    230237          {
    231             if ( clientListPerm_[clientID].find( (*itvec).objID) != clientListPerm_[clientID].end() )
     238            if ( objectListPerm.find( (*itvec).objID) != objectListPerm.end() )
    232239      {
    233240        // we already have the object in our map
    234241        //obj bleibt in liste und permanente prio wird berechnet
    235         clientListPerm_[clientID][(*itvec).objID].objDiffGS = currentGamestateID - clientListPerm_[clientID][(*itvec).objID].objCurGS;
     242        objectListPerm[(*itvec).objID].objDiffGS = currentGamestateID - objectListPerm[(*itvec).objID].objCurGS;
    236243        continue;//check next objId
    237244      }
Note: See TracChangeset for help on using the changeset viewer.