- Timestamp:
- Jun 16, 2013, 11:12:31 PM (12 years ago)
- Branches:
- master
- Children:
- 032e550, d3e8f60
- Parents:
- ff2133a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
rff2133a r5b1e31e 119 119 120 120 sock = socket(AF_INET, SOCK_DGRAM, 0); 121 if (sock < 0) error("Opening socket"); 121 if (sock < 0) 122 error("Opening socket"); 122 123 length = sizeof(server); 123 124 bzero(&server,length); … … 149 150 // set targets for all chasing players (or make them attack if they're close enough) 150 151 for (it = mapPlayers.begin(); it != mapPlayers.end(); it++) { 151 //Player* p = &it->second; 152 it->second.updateTarget(mapPlayers); 153 154 /* 155 if (p->isChasing) { 156 p->target.x = mapPlayers[p->targetPlayer].pos.x; 157 p->target.y = mapPlayers[p->targetPlayer].pos.y; 158 159 if (posDistance(p->pos, p->target.toFloat()) <= p->range) { 160 p->target.x = p->pos.x; 161 p->target.y = p->pos.y; 162 163 p->isChasing = false; 164 p->isAttacking = true; 165 p->timeAttackStarted = getCurrentMillis(); 166 } 167 } 168 */ 152 if (it->second.updateTarget(mapPlayers)) { 153 serverMsg.type = MSG_TYPE_PLAYER; 154 it->second.serialize(serverMsg.buffer); 155 156 map<unsigned int, Player>::iterator it2; 157 for (it2 = mapPlayers.begin(); it2 != mapPlayers.end(); it2++) 158 { 159 if ( sendMessage(&serverMsg, sock, &(it2->second.addr)) < 0 ) 160 error("sendMessage"); 161 } 162 } 169 163 } 170 164 … … 187 181 it->second.target.x = it->second.pos.x; 188 182 it->second.target.y = it->second.pos.y; 183 it->second.isChasing = false; 189 184 broadcastMove = true; 190 185 break; … … 689 684 mapPlayers[id].target.y = y; 690 685 686 mapPlayers[id].isChasing = false; 687 mapPlayers[id].isAttacking = false; 688 691 689 serverMsg.type = MSG_TYPE_PLAYER_MOVE; 692 690
Note:
See TracChangeset
for help on using the changeset viewer.