EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
EVEMarshalStringTable.cpp
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Captnoord
24 */
25 
26 #include "eve-common.h"
27 
29 
30 /* we made up this list so we have efficient string communication with the client */
43 const char* const MarshalStringTable::s_mStringTable[] =
44 {
45  "*corpid",
46  "*locationid",
47  "age",
48  "Asteroid",
49  "authentication",
50  "ballID",
51  "beyonce",
52  "bloodlineID",
53  "capacity",
54  "categoryID",
55  "character",
56  "characterID",
57  "characterName",
58  "characterType",
59  "charID",
60  "chatx",
61  "clientID",
62  "config",
63  "contraband",
64  "corporationDateTime",
65  "corporationID",
66  "createDateTime",
67  "customInfo",
68  "description",
69  "divisionID",
70  "DoDestinyUpdate",
71  "dogmaIM",
72  "EVE System",
73  "flag",
74  "foo.SlimItem",
75  "gangID",
76  "Gemini",
77  "gender",
78  "graphicID",
79  "groupID",
80  "header",
81  "idName",
82  "invbroker",
83  "itemID",
84  "items",
85  "jumps",
86  "line",
87  "lines",
88  "locationID",
89  "locationName",
90  "macho.CallReq",
91  "macho.CallRsp",
92  "macho.MachoAddress",
93  "macho.Notification",
94  "macho.SessionChangeNotification",
95  "modules",
96  "name",
97  "objectCaching",
98  "objectCaching.CachedObject",
99  "OnChatJoin",
100  "OnChatLeave",
101  "OnChatSpeak",
102  "OnGodmaShipEffect",
103  "OnItemChange",
104  "OnModuleAttributeChange",
105  "OnMultiEvent",
106  "orbitID",
107  "ownerID",
108  "ownerName",
109  "quantity",
110  "raceID",
111  "RowClass",
112  "securityStatus",
113  "Sentry Gun",
114  "sessionchange",
115  "singleton",
116  "skillEffect",
117  "squadronID",
118  "typeID",
119  "used",
120  "userID",
121  "util.CachedObject",
122  "util.IndexRowset",
123  "util.Moniker",
124  "util.Row",
125  "util.Rowset",
126  "*multicastID",
127  "AddBalls",
128  "AttackHit3",
129  "AttackHit3R",
130  "AttackHit4R",
131  "DoDestinyUpdates",
132  "GetLocationsEx",
133  "InvalidateCachedObjects",
134  "JoinChannel",
135  "LSC",
136  "LaunchMissile",
137  "LeaveChannel",
138  "OID+",
139  "OID-",
140  "OnAggressionChange",
141  "OnCharGangChange",
142  "OnCharNoLongerInStation",
143  "OnCharNowInStation",
144  "OnDamageMessage",
145  "OnDamageStateChange",
146  "OnEffectHit",
147  "OnGangDamageStateChange",
148  "OnLSC",
149  "OnSpecialFX",
150  "OnTarget",
151  "RemoveBalls",
152  "SendMessage",
153  "SetMaxSpeed",
154  "SetSpeedFraction",
155  "TerminalExplosion",
156  "address",
157  "alert",
158  "allianceID",
159  "allianceid",
160  "bid",
161  "bookmark",
162  "bounty",
163  "channel",
164  "charid",
165  "constellationid",
166  "corpID",
167  "corpid",
168  "corprole",
169  "damage",
170  "duration",
171  "effects.Laser",
172  "gangid",
173  "gangrole",
174  "hqID",
175  "issued",
176  "jit",
177  "languageID",
178  "locationid",
179  "machoVersion",
180  "marketProxy",
181  "minVolume",
182  "orderID",
183  "price",
184  "range",
185  "regionID",
186  "regionid",
187  "role",
188  "rolesAtAll",
189  "rolesAtBase",
190  "rolesAtHQ",
191  "rolesAtOther",
192  "shipid",
193  "sn",
194  "solarSystemID",
195  "solarsystemid",
196  "solarsystemid2",
197  "source",
198  "splash",
199  "stationID",
200  "stationid",
201  "target",
202  "userType",
203  "userid",
204  "volEntered",
205  "volRemaining",
206  "weapon",
207  "agent.missionTemplatizedContent_BasicKillMission",
208  "agent.missionTemplatizedContent_ResearchKillMission",
209  "agent.missionTemplatizedContent_StorylineKillMission",
210  "agent.missionTemplatizedContent_GenericStorylineKillMission",
211  "agent.missionTemplatizedContent_BasicCourierMission",
212  "agent.missionTemplatizedContent_ResearchCourierMission",
213  "agent.missionTemplatizedContent_StorylineCourierMission",
214  "agent.missionTemplatizedContent_GenericStorylineCourierMission",
215  "agent.missionTemplatizedContent_BasicTradeMission",
216  "agent.missionTemplatizedContent_ResearchTradeMission",
217  "agent.missionTemplatizedContent_StorylineTradeMission",
218  "agent.missionTemplatizedContent_GenericStorylineTradeMission",
219  "agent.offerTemplatizedContent_BasicExchangeOffer",
220  "agent.offerTemplatizedContent_BasicExchangeOffer_ContrabandDemand",
221  "agent.offerTemplatizedContent_BasicExchangeOffer_Crafting",
222  "agent.LoyaltyPoints",
223  "agent.ResearchPoints",
224  "agent.Credits",
225  "agent.Item",
226  "agent.Entity",
227  "agent.Objective",
228  "agent.FetchObjective",
229  "agent.EncounterObjective",
230  "agent.DungeonObjective",
231  "agent.TransportObjective",
232  "agent.Reward",
233  "agent.TimeBonusReward",
234  "agent.MissionReferral",
235  "agent.Location",
236  "agent.StandardMissionDetails",
237  "agent.OfferDetails",
238  "agent.ResearchMissionDetails",
239  "agent.StorylineMissionDetails",
240 };
241 
242 /*rawstrings = "\n'*fleetid'\n'*multicastID'\n'*solarsystemid&corpid'\n'*stationid&corpid'\n'*stationid&corpid&corprole'
243  * \n'+clientID'\n'1 minute'\n'AccessControl'\n'CacheOK'\n'DoDestinyUpdate'\n'EN'\n'EVE-EVE-RELEASE'\n'GetCachableObject'
244  * \n'GetExpiryDate'\n'GetLocationsEx'\n'GetNewPriceHistory'\n'GetOldPriceHistory'\n'GetOrders'
245  * \n'HANDSHAKE_INCOMPATIBLEREGION'\n'InvalidateCachedObjects'\n'JoinChannel'\n'LSC'\n'LeaveChannel'\n'MarketRegion'
246  * \n'Method Call'\n'OID-'\n'OnAccountChange'\n'OnAgentMissionChange'\n'OnAggressionChange'\n'OnCfgDataChanged'
247  * \n'OnCharNoLongerInStation'\n'OnCharNowInStation'\n'OnContactLoggedOn'\n'OnCorporationMemberChanged'
248  * \n'OnCorporationVoteCaseOptionChanged'\n'OnDockingAccepted'\n'OnFleetActive'\n'OnFleetJoin'\n'OnFleetLeave'
249  * \n'OnFleetMemberChanged'\n'OnFleetStateChange'\n'OnItemsChanged'\n'OnJumpQueueUpdate'\n'OnLSC'
250  * \n'OnMachoObjectDisconnect'\n'OnMessage'\n'OnMultiEvent'\n'OnNotifyPreload'\n'OnOwnOrderChanged'
251  * \n'OnProbeStateChanged'\n'OnProbeWarpEnd'\n'OnProbeWarpStart'\n'OnRemoteMessage'\n'OnSquadActive'
252  * \n'OnStandingsModified'\n'OnSystemScanStarted'\n'OnSystemScanStopped'\n'OnTarget'\n'PlaceCharOrder'
253  * \n'ProcessGodmaPrimeLocation'\n'SendMessage'\n'__MultiEvent'\n'account'\n'address'\n'allianceid'
254  * \n'authentication'\n'autodepth_stencilformat'\n'avgPrice'\n'baseID'\n'beyonce'\n'bid'\n'bloodlineID'\n'boot_build'
255  * \n'boot_codename'\n'boot_region'\n'boot_version'\n'build'\n'ccp'\n'challenge_responsehash'\n'channel'\n'character'
256  * \n'charid'\n'charmgr'\n'clientID'\n'clock'\n'codename'\n'columns'\n'compressedPart'\n'config'\n'config.Attributes'
257  * \n'config.Bloodlines'\n'config.BulkData.allianceshortnames'\n'config.BulkData.billtypes'\n'config.BulkData.bptypes'
258  * \n'config.BulkData.categories'\n'config.BulkData.certificaterelationships'\n'config.BulkData.certificates'
259  * \n'config.BulkData.dgmattribs'\n'config.BulkData.dgmeffects'\n'config.BulkData.dgmtypeattribs'
260  * \n'config.BulkData.dgmtypeeffects'\n'config.BulkData.graphics'\n'config.BulkData.groups'
261  * \n'config.BulkData.invmetatypes'\n'config.BulkData.invtypereactions'\n'config.BulkData.locations'
262  * \n'config.BulkData.locationwormholeclasses'\n'config.BulkData.mapcelestialdescriptions'\n'config.BulkData.metagroups'
263  * \n'config.BulkData.owners'\n'config.BulkData.ramactivities'\n'config.BulkData.ramaltypes'
264  * \n'config.BulkData.ramaltypesdetailpercategory'\n'config.BulkData.ramaltypesdetailpergroup'
265  * \n'config.BulkData.ramcompletedstatuses'\n'config.BulkData.invtypematerials'\n'config.BulkData.ramtyperequirements'
266  * \n'config.BulkData.shiptypes'\n'config.BulkData.tickernames'\n'config.BulkData.types'\n'config.BulkData.units'
267  * \n'config.Flags'\n'config.InvContrabandTypes'\n'config.Races'\n'config.StaticLocations'\n'config.StaticOwners'
268  * \n'config.Units'\n'constellationid'\n'contractMgr'\n'corpAccountKey'\n'corpRegistry'\n'corpStationMgr'\n'corpid'
269  * \n'corporationSvc'\n'corprole'\n'crypting_securityprovidertype'\n'crypting_sessionkeylength'
270  * \n'crypting_sessionkeymethod'\n'dogmaIM'\n'duration'\n'entity'\n'explosioneffectssenabled'\n'facWarMgr'\n'fittingMgr'
271  * \n'fullscreen_resolution'\n'fleetSvc'\n'fleetObjectHandler'\n'fleetbooster'\n'fleetid'\n'fleetrole'\n'genderID'
272  * \n'handshakefunc_output'\n'handshakefunc_result'\n'header'\n'highPrice'\n'historyDate'\n'hqID'\n'inDetention'
273  * \n'invbroker'\n'issued'\n'jit'\n'jumps'\n'languageID'\n'locationid'\n'loggedOnUserCount'\n'lowPrice'\n'macho.CallReq'
274  * \n'macho.CallRsp'\n'macho.ErrorResponse'\n'macho.MachoAddress'\n'macho.Notification'\n'macho.PingReq'\n'macho.PingRsp'
275  * \n'macho.SessionChangeNotification'\n'macho.SessionInitialStateNotification'\n'machoNet'\n'machoNet.serviceInfo'
276  * \n'machoVersion'\n'macho_version'\n'map'\n'market'\n'marketProxy'\n'maxSessionTime'\n'minVolume'
277  * \n'network_computername'\n'objectCaching'\n'objectCaching.CachedMethodCallResult'\n'objectCaching.CachedObject'
278  * \n'orderID'\n'orders'\n'origin'\n'pixel_shader_version'\n'presentation_interval'\n'price'\n'processor_architecture'
279  * \n'processor_identifier'\n'raceID'\n'range'\n'reason'\n'reasonArgs'\n'reasonCode'\n'region'\n'regionID'\n'regionid'
280  * \n'role'\n'rolesAtAll'\n'rolesAtBase'\n'rolesAtHQ'\n'rolesAtOther'\n'scanMgr'\n'sessionInfo'\n'sessionMgr'
281  * \n'sessionchange'\n'shipid'\n'sn'\n'solarSystemID'\n'solarsystemid'\n'solarsystemid2'\n'squadid'\n'standing2'
282  * \n'station'\n'stationID'\n'stationSvc'\n'stationid'\n'tutorialSvc'\n'typeID'\n'userType'\n'user_logonqueueposition'
283  * \n'userid'\n'utcmidnight'\n'utcmidnight_or_3hours'\n'util.CachedObject'\n'util.KeyVal'\n'util.Rowset'\n'version'
284  * \n'versionCheck'\n'vertex_shader_version'\n'volEntered'\n'volRemaining'\n'volume'\n'warRegistry'\n'warfactionid'
285  * \n'wingid'\n"
286  */
287 
288 const size_t MarshalStringTable::s_mStringTableSize = sizeof( MarshalStringTable::s_mStringTable ) / sizeof( const char* );
289 
291 {
292  for( uint8 i = 1; i <= s_mStringTableSize; i++ )
293  mStringTableMap.insert( std::make_pair( hash( LookupString( i ) ), i ) );
294 }
295 
296 /* lookup a index using a string */
297 uint8 MarshalStringTable::LookupIndex( const std::string& str )
298 {
299  return LookupIndex( str.c_str() );
300 }
301 
302 /* lookup a index using a string */
304 {
305  StringTableMapConstItr res = mStringTableMap.find( hash( str ) );
306  if( mStringTableMap.end() == res )
307  return STRING_TABLE_ERROR;
308 
309  return res->second;
310 }
311 
313 {
314  if( --index < s_mStringTableSize )
315  return s_mStringTable[ index ];
316  else
317  return nullptr;
318 }
unsigned __int8 uint8
Definition: eve-compat.h:46
static const size_t s_mStringTableSize
StringTableMap::const_iterator StringTableMapConstItr
StringTableMap mStringTableMap
static const char *const s_mStringTable[]
#define STRING_TABLE_ERROR
const char * LookupString(uint8 index)
lookup a string using a index
uint32 hash(const char *str)
djb2 algorithm taken from http://www.cse.yorku.ca/~oz/hash.html slightly modified ...
uint8 LookupIndex(const std::string &str)
lookup a index nr using a string