void NetGameClient::DoObjDamage(NetMsg* msg) { if (!msg) return; NetObjDamage obj_damage; obj_damage.Unpack(msg->Data()); Ship* ship = FindShipByObjID(obj_damage.GetObjID()); if (ship) { Sim* sim = Sim::GetSim(); Shot* shot = FindShotByObjID(obj_damage.GetShotID()); const Ship* owner = 0; const char* owner_name = "[NET]"; ship->InflictNetDamage(obj_damage.GetDamage(), shot); if (shot && sim) { if (shot->Owner()) { owner = shot->Owner(); owner_name = owner->Name(); } if (shot->IsMissile()) { SimRegion* region = ship->GetRegion(); float scale = ship->Design()->explosion_scale; if (scale <= 0) scale = ship->Design()->scale; if (owner) { const ShipDesign* owner_design = owner->Design(); if (owner_design && owner_design->scale < scale) scale = (float) owner_design->scale; } sim->CreateExplosion(shot->Location(), Point(), Explosion::SHOT_BLAST, 20.0f * scale, scale, region); } if (!shot->IsBeam()) { if (owner) { ShipStats* stats = ShipStats::Find(owner_name); if (stats) { if (shot->IsPrimary()) stats->AddGunHit(); else if (shot->Damage() > 0) stats->AddMissileHit(); } } shot->Destroy(); } } } }
void NetGameClient::DoWepDestroy(NetMsg* msg) { if (!msg) return; NetWepDestroy destroy; destroy.Unpack(msg->Data()); Shot* shot = FindShotByObjID(destroy.GetObjID()); if (shot) { if (shot->IsBeam()) ::Print("NetGameClient::DoWepDestroy shot '%s'\n", shot->Name()); shot->Destroy(); } }