Ares
Static Public Member Functions

AresNetEvent::Handlers Class Reference

#include <src/Misc/Network.h>

List of all members.

Static Public Member Functions

static void RaiseTrenchRedirectClick (BuildingClass *Source, CellStruct *Target)
static void RespondToTrenchRedirectClick (NetworkEvent *Event)
static void RaiseFirewallToggle (HouseClass *Source)
static void RespondToFirewallToggle (NetworkEvent *Event)

Member Function Documentation

void AresNetEvent::Handlers::RaiseFirewallToggle ( HouseClass *  Source) [static]
                                                                 {
        NetworkEvent * Event = new NetworkEvent();
        Event->Kind = AresNetEvent::aev_FirewallToggle;
        Event->HouseIndex = byte(Source->ArrayIndex);

        Networking::AddEvent(Event);
        delete Event;
}
void AresNetEvent::Handlers::RaiseTrenchRedirectClick ( BuildingClass *  Source,
CellStruct *  Target 
) [static]
                                                                                             {
        NetworkEvent * Event = new NetworkEvent();
        Event->Kind = AresNetEvent::aev_TrenchRedirectClick;
        Event->HouseIndex = byte(Source->Owner->ArrayIndex);
        byte *ExtraData = Event->ExtraData;

        NetID SourceObject, TargetCoords;

        TargetCoords.Pack(Target);
        memcpy(ExtraData, &TargetCoords, sizeof(TargetCoords));
        ExtraData += sizeof(TargetCoords);

        SourceObject.Pack(Source);
        memcpy(ExtraData, &SourceObject, sizeof(SourceObject));
        ExtraData += sizeof(SourceObject);

        Networking::AddEvent(Event);
        delete Event;
}
void AresNetEvent::Handlers::RespondToFirewallToggle ( NetworkEvent *  Event) [static]
                                                                      {
        if(HouseClass * pSourceHouse = HouseClass::Array->GetItem(Event->HouseIndex)) {
                HouseExt::ExtData *pData = HouseExt::ExtMap.Find(pSourceHouse);
                bool FS = pData->FirewallActive;
                FS = !FS;
                pData->SetFirestormState(FS);
                pData->FirewallRecalc = 1;
        }
}
void AresNetEvent::Handlers::RespondToTrenchRedirectClick ( NetworkEvent *  Event) [static]
                                                                           {
        NetID *ID = reinterpret_cast<NetID *>(Event->ExtraData);
        if(CellClass * pTargetCell = ID->UnpackCell()) {
                ++ID;
                if(BuildingClass * pSourceBuilding = ID->UnpackBuilding()) {
                        /*
                                pSourceBuilding == selected building the soldiers are in
                                pTargetCell == cell the user clicked on; event fires only on buildings which showed the enter cursor
                        */
                        BuildingExt::ExtData* sourceBuildingExt = BuildingExt::ExtMap.Find(pSourceBuilding);
                        BuildingClass* targetBuilding = pTargetCell->GetBuilding();
                        sourceBuildingExt->doTraverseTo(targetBuilding); // check has happened before the enter cursor appeared
                }
        }

}

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines