void InputServerReplay::update() { uint32 pid = 0; for(size_t i=0; i<m_players.size(); ++i) { const RepPlayer &pl = m_players[i]; if(m_pos>=pl.begin_frame && m_pos<pl.begin_frame+pl.num_frame) { InputCont &inp = m_inputs[i]; RepInput &rd = inp[m_pos-pl.begin_frame]; m_is[pid].update(rd); ++pid; } else if(m_pos==pl.begin_frame+pl.num_frame) { erasePlayer(i); } } { LevelEditorCommand s; s.frame = m_pos; std::pair<LECCont::iterator, LECCont::iterator> lecs = std::equal_range(m_lecs.begin(), m_lecs.end(), s, [&](const LevelEditorCommand &a, const LevelEditorCommand &b){ return a.frame<b.frame; }); for(LECCont::iterator i=lecs.first; i!=lecs.second; ++i) { atmGetGame()->handleLevelEditorCommands(*i); } } ++m_pos; }
/* ========================================================================= */ void CNetwork::proc_PK_OBJ_REMOVE( int res, char *dat ) { /* for( int i=0; i < res; i++ ) printf( "%c", message[i] ); printf( "\n" ); printf( "|%d|%d|", res, message[2] ); */ int ObjType = 0; int PlayerNo = 0; int x = 0; int y = 0; procPacket( dat, "%d %h %h %h", &ObjType, &PlayerNo, &x, &y); /* printf( "ObjType = %d\n", ObjType); printf( "PlayerNo = %d\n", PlayerNo); printf( "x = %d\n", x); printf( "y = %d\n", y); */ // オブジェクトタイプ switch( ObjType ) { case 2: // PC erasePlayer( PlayerNo ); break; default: MB( "Error:オブジェクトタイプが未定義です。(proc_PK_OBJ_REMOVE)" ); break; } }
void movePlayer(PLAYER (*ppp)[], int i, int dir) { PLAYER *p = &(*ppp)[i]; POSITION oldPosition = (*p).obj.pos; POSITION newPosition = getNewPosition(oldPosition, dir); if (isPositionValid(newPosition, dir)) { // save move if not yet finished: if ((*p).finished != 1) { saveMove(p, dir); } // if player crossed the line, finished flag is set to true: if (crossedTheLine(oldPosition, dir)) { (*p).finished = 1; } int symbol = getSymbolOnTheTrack(oldPosition); erasePlayer(p); // if player was on the finish line, draw finish line: if (symbol == '|') { printChar('|', oldPosition); } (*p).obj.pos = newPosition; // so that if two were on the same spot both get printed: printAllPlayers(ppp); // so that it if two are on the same spot the last that arrived gets printed: printPlayer(p); } }