- Timestamp:
- Jun 9, 2013, 9:30:32 PM (12 years ago)
- Branches:
- master
- Children:
- ff2133a
- Parents:
- 8c74150
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
r8c74150 r11d21ee 145 145 timeLastUpdated = curTime; 146 146 147 map<unsigned int, Player>::iterator it; 148 149 // set targets for all chasing players (or make them attack if they're close enough) 150 for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) { 151 Player* p = &it->second; 152 153 if (p->isChasing) { 154 p->target.x = mapPlayers[p->targetPlayer].pos.x; 155 p->target.y = mapPlayers[p->targetPlayer].pos.y; 156 157 if (posDistance(p->pos, p->target.toFloat()) <= p->range) { 158 p->target.x = p->pos.x; 159 p->target.y = p->pos.y; 160 161 p->isChasing = false; 162 p->isAttacking = true; 163 p->timeAttackStarted = getCurrentMillis(); 164 } 165 } 166 } 167 147 168 // move all players 148 169 // maybe put this in a separate method 149 map<unsigned int, Player>::iterator it;150 170 FLOAT_POSITION oldPos; 151 171 bool broadcastMove = false; … … 778 798 779 799 Player* source = &mapPlayers[id]; 780 source->timeAttackStarted = getCurrentMillis();781 800 source->targetPlayer = targetId; 782 source->isAttacking = true; 783 801 source->isChasing = true; 802 803 // this is irrelevant since the client doesn't even listen for START_ATTACK messages 804 // actually, the client should not ignore this and should instead perform the same movement 805 // algorithm on its end (following the target player until in range) that the server does. 806 // Once the attacker is in range, the client should stop movement and wait for messages 807 // from the server 784 808 serverMsg.type = MSG_TYPE_START_ATTACK; 785 809 memcpy(serverMsg.buffer, &id, 4);
Note:
See TracChangeset
for help on using the changeset viewer.