Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
NetworkObjectClass.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE_NETWORKOBJECTCLASS_H
13#define TT_INCLUDE_NETWORKOBJECTCLASS_H
14
15class BitStreamClass;
16class Vector3;
17class StringClass;
18
19enum PACKET_TIER_ENUM
20{
21 PACKET_TIER_CREATION,
22 PACKET_TIER_RARE,
23 PACKET_TIER_OCCASIONAL,
24 PACKET_TIER_FREQUENT,
25
26 PACKET_TIER_COUNT
27};
28class NetworkObjectClass
29{
30public:
31 typedef enum
32 {
33 BIT_MASK_FREQUENT = 0x01,
34 BIT_MASK_OCCASIONAL = 0x02,
35 BIT_MASK_RARE = 0x04,
36 BIT_MASK_CREATION = 0x08,
37
38 BIT_FREQUENT = 0x01,
39 BIT_OCCASIONAL = 0x03,
40 BIT_RARE = 0x07,
41 BIT_CREATION = 0x0f,
42
43 BIT_SUPPRESS_UPDATES = 0x10, // Set when the local end should not send updates to the remote end. This happens if the remote end created the object (by receiving a BIT_CREATION message), when the remote end has been informed that the object has been deleted, or when an object has not yet been created on the remote end.
44 } DIRTY_BIT;
45 enum
46 {
47 MAX_CLIENT_COUNT = 128
48 };
49 NetworkObjectClass (void);
50 virtual ~NetworkObjectClass (void);
51 int Get_Network_ID (void) const { return NetworkID; }
52 void Set_Network_ID (int id);
53#ifdef TTLE_EXPORTS
54 int Get_Created_By_Packet_ID (void) const { return CreatedByPacketID; }
55 void Set_Created_By_Packet_ID (int id);
56#endif
57 virtual uint32 Get_Network_Class_ID (void) const { return 0; }
58 virtual void Import_Creation (BitStreamClass &packet) {}
59 virtual void Import_Rare (BitStreamClass &packet) {}
60 virtual void Import_Occasional (BitStreamClass &packet) {}
61 virtual void Import_Frequent (BitStreamClass &packet) {}
62 virtual void Export_Creation (BitStreamClass &packet) {}
63 virtual void Export_Rare (BitStreamClass &packet) {}
64 virtual void Export_Occasional (BitStreamClass &packet) {}
65 virtual void Export_Frequent (BitStreamClass &packet) {}
66 virtual void Network_Think (void) {}
67 bool Is_Delete_Pending (void) { return IsDeletePending; }
68 virtual void Set_Delete_Pending (void);
69 void Set_Is_Delete_Pending (bool pending) { IsDeletePending = pending; }
70 virtual void Delete (void) = 0;
71 void Set_App_Packet_Type (BYTE type) { AppPacketType = type; }
72 BYTE Get_App_Packet_Type (void) { return AppPacketType; }
73 virtual void Set_Object_Dirty_Bit (DIRTY_BIT dirty_bit, bool onoff);
74 virtual void Set_Object_Dirty_Bit (int client_id, DIRTY_BIT dirty_bit, bool onoff);
75 void Set_Object_Dirty_Bitx(int client_id, DIRTY_BIT dirty_bit, bool onoff);
76 virtual void Clear_Object_Dirty_Bits (void);
77 virtual bool Get_Object_Dirty_Bit (int client_id, DIRTY_BIT dirty_bit);
78 virtual BYTE Get_Object_Dirty_Bits (int client_id);
79 virtual void Set_Object_Dirty_Bits (int client_id, BYTE bits);
80 virtual bool Is_Client_Dirty (int client_id);
81 void Set_Dirty_Bits(uint8 dirtyBits);
82 inline bool Get_Object_Dirty_Bit_2 (int client_id, DIRTY_BIT dirty_bit)
83 {
84 return ((ClientStatus[client_id] & dirty_bit) == dirty_bit);
85 }
86 inline BYTE Get_Object_Dirty_Bits_2 (int client_id)
87 {
88 return ClientStatus[client_id];
89 }
90 virtual int Get_Vis_ID (void) { return -1; }
91 virtual bool Get_World_Position (Vector3 &pos) const { return false; }
92 virtual float Get_Filter_Distance(void) const { return 10000.0f; }
93 void Reset_Client_Hint_Count(int client_id);
94 void Increment_Client_Hint_Count(int client_id);
95 void Hint_To_All_Clients(void);
96 BYTE Get_Client_Hint_Count(int client_id);
97 inline BYTE Get_Client_Hint_Count_2(int client_id)
98 {
99 return UpdateInfo[client_id].ClientHintCount;
100 }
101 void Reset_Import_State_Count (void) { ImportStateCount = 0; }
102 void Increment_Import_State_Count (void) { ImportStateCount ++; }
103 int Get_Import_State_Count (void) { return ImportStateCount; }
104 void Reset_Last_Clientside_Update_Time (void);
105 void Set_Last_Clientside_Update_Time (ULONG time);
106 ULONG Get_Last_Clientside_Update_Time (void) { return LastClientsideUpdateTime; }
107 TT_DEPRECATED("This function is no longer necessary and the member variable it uses has been hijacked to host a different variable.") int Get_Clientside_Update_Frequency(void);
108 bool Belongs_To_Client(int client_id);
109 unsigned char Get_Frequent_Update_Export_Size(void) {return(FrequentExportPacketSize);}
110 void Set_Frequent_Update_Export_Size(unsigned char size) {FrequentExportPacketSize = size;}
111 unsigned long Get_Last_Update_Time(int client_id);
112 unsigned short Get_Update_Rate(int client_id);
113 void Set_Last_Update_Time(int client_id, unsigned long time);
114 void Set_Update_Rate(int client_id, unsigned short rate);
115 virtual bool Is_Tagged(void) { return false; }
116 virtual void Get_Description(StringClass & description) {}
117 void Set_Unreliable_Override(bool flag) {UnreliableOverride = flag;}
118 bool Get_Unreliable_Override(void) {return UnreliableOverride;}
119#if !defined(DDBEDIT) && !defined(W3DVIEWER)
120 static void Set_Is_Server(bool flag) { IsServer = flag; }
121#endif
122 void Set_Cached_Priority (float priority);
123 virtual float Get_Cached_Priority (void) const { return CachedPriority; }
124 inline void Set_Cached_Priority_2 (int client_id, float priority)
125 {
126 CachedPriority_2[client_id] = priority;
127 }
128 inline float Get_Cached_Priority_2 (int client_id) const
129 {
130 return(CachedPriority_2[client_id]);
131 }
132 void Set_Last_Object_Id_I_Damaged(int id) {LastObjectIdIDamaged = id;}
133 int Get_Last_Object_Id_I_Damaged(void) const {return LastObjectIdIDamaged;}
134 void Set_Last_Object_Id_I_Got_Damaged_By(int id) {LastObjectIdIGotDamagedBy = id;}
135 int Get_Last_Object_Id_I_Got_Damaged_By(void) const {return LastObjectIdIGotDamagedBy;}
136
137 ULONG getLastHintRequestTime() const { return LastHintRequestTime; }
138 void setLastHintRequestTime(ULONG _lastHintRequestTime) { LastHintRequestTime = _lastHintRequestTime; }
139private:
140 int NetworkID; // 0004
141#ifdef TTLE_EXPORTS
142 int CreatedByPacketID;
143#endif
144 struct PerClientUpdateInfoStruct {
145 unsigned long LastUpdateTime;
146 unsigned short UpdateRate;
147 BYTE ClientHintCount;
148 } UpdateInfo [MAX_CLIENT_COUNT]; // 0008
149 BYTE ClientStatus[MAX_CLIENT_COUNT]; // 0408
150 int ImportStateCount; // 0488
151 ULONG LastClientsideUpdateTime; // 048C
152 ULONG ClientsideUpdateFrequencySampleStartTime; // 0490
153 int ClientsideUpdateFrequencySampleCount; // 0494
154 ULONG LastHintRequestTime; // 0498; originally ClientsideUpdateRate, but this offset has been hijacked to host the current variable instead
155 bool IsDeletePending; // 049C
156 BYTE AppPacketType; // 049D
157 int LastObjectIdIDamaged; // 04A0
158 int LastObjectIdIGotDamagedBy; // 04A4
159 unsigned char FrequentExportPacketSize; // 04A8
160 float CachedPriority; // 04AC
161 float CachedPriority_2[MAX_CLIENT_COUNT]; // 04B0
162 bool UnreliableOverride; // 06B0
163#if !defined(DDBEDIT) && !defined(W3DVIEWER)
164 static REF_DECL(bool, IsServer);
165#endif
166}; // 06B1
167
168#endif