Changeset 8795a38 in network-game for server/server.cpp
- Timestamp:
- Jun 9, 2013, 7:27:52 PM (12 years ago)
- Branches:
- master
- Children:
- 8c74150
- Parents:
- fbcfc35
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/server.cpp
rfbcfc35 r8795a38 325 325 if (it->second.isAttacking && it->second.timeAttackStarted+it->second.attackCooldown <= getCurrentMillis()) { 326 326 it->second.isAttacking = false; 327 cout << "Attack animation is complete" << endl; 327 328 328 329 //send everyone an ATTACK message … … 355 356 mapProjectiles[proj.id] = proj; 356 357 358 int x = it->second.pos.x; 359 int y = it->second.pos.y; 360 357 361 serverMsg.type = MSG_TYPE_PROJECTILE; 358 memcpy(serverMsg.buffer, &it->second.pos.x, 4); 359 memcpy(serverMsg.buffer+4, &it->second.pos.y, 4); 360 memcpy(serverMsg.buffer+8, &it->second.targetPlayer, 4); 362 memcpy(serverMsg.buffer, &proj.id, 4); 363 memcpy(serverMsg.buffer+4, &x, 4); 364 memcpy(serverMsg.buffer+8, &y, 4); 365 memcpy(serverMsg.buffer+12, &it->second.targetPlayer, 4); 361 366 }else { 362 367 cout << "Invalid attack type: " << it->second.attackType << endl; … … 389 394 390 395 // send a PLAYER message after dealing damage 391 Player* target = &mapPlayers[it ->second.targetPlayer];396 Player* target = &mapPlayers[itProj->second.target]; 392 397 393 398 target->health -= itProj->second.damage; … … 775 780 source->timeAttackStarted = getCurrentMillis(); 776 781 source->targetPlayer = targetId; 782 source->isAttacking = true; 777 783 778 784 serverMsg.type = MSG_TYPE_START_ATTACK;
Note:
See TracChangeset
for help on using the changeset viewer.