MemoryInit.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: MemoryInit.cpp
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: MemoryInit.cpp
  36. //
  37. // Created: Steven Johnson, August 2001
  38. //
  39. // Desc: Memory manager
  40. //
  41. // ----------------------------------------------------------------------------
  42. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  43. // SYSTEM INCLUDES
  44. // USER INCLUDES
  45. #include "Lib/BaseType.h"
  46. #include "Common/GameMemory.h"
  47. #ifdef _INTERNAL
  48. // for occasional debugging...
  49. //#pragma optimize("", off)
  50. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  51. #endif
  52. //-----------------------------------------------------------------------------
  53. void userMemoryManagerGetDmaParms(Int *numSubPools, const PoolInitRec **pParms)
  54. {
  55. static const PoolInitRec defaultDMA[7] =
  56. {
  57. // name, allocsize, initialcount, overflowcount
  58. { "dmaPool_16", 16, 130000, 10000 },
  59. { "dmaPool_32", 32, 250000, 10000 },
  60. { "dmaPool_64", 64, 100000, 10000 },
  61. { "dmaPool_128", 128, 80000, 10000 },
  62. { "dmaPool_256", 256, 20000, 5000 },
  63. { "dmaPool_512", 512, 16000, 5000 },
  64. { "dmaPool_1024", 1024, 6000, 1024}
  65. };
  66. *numSubPools = 7;
  67. *pParms = defaultDMA;
  68. }
  69. //-----------------------------------------------------------------------------
  70. struct PoolSizeRec
  71. {
  72. const char* name;
  73. Int initial;
  74. Int overflow;
  75. };
  76. //-----------------------------------------------------------------------------
  77. // And please be careful of duplicates. They are not rejected.
  78. // not const -- we might override from INI
  79. static PoolSizeRec sizes[] =
  80. {
  81. { "PartitionContactListNode", 2048, 512 },
  82. { "BattleshipUpdate", 32, 32 },
  83. { "FlyToDestAndDestroyUpdate", 32, 32 },
  84. { "MusicTrack", 32, 32 },
  85. { "PositionalSoundPool", 32, 32 },
  86. { "GameMessage", 2048, 32 },
  87. { "NameKeyBucketPool", 9000, 1024 },
  88. { "ObjectSellInfo", 16, 16 },
  89. { "ProductionPrerequisitePool", 1024, 32 },
  90. { "RadarObject", 512, 32 },
  91. { "ResourceGatheringManager", 16, 16 },
  92. { "SightingInfo", 8192, 2048 },// Looks big, but all 3000 objects used to have 4 just built in.
  93. { "SpecialPowerTemplate", 84, 32 },
  94. { "StateMachinePool", 32, 32 },
  95. { "TeamPool", 128, 32 }, // if you increase this, increase player/team relation map pools
  96. { "PlayerRelationMapPool", 128, 32 },
  97. { "TeamRelationMapPool", 128, 32 },
  98. { "TeamPrototypePool", 256, 32 },
  99. { "TerrainType", 256, 32 },
  100. { "ThingTemplatePool", 2120, 32 },
  101. { "TunnelTracker", 16, 16 },
  102. { "Upgrade", 16, 16 },
  103. { "UpgradeTemplate", 128, 16 },
  104. { "Anim2D", 32, 32 },
  105. { "CommandButton", 1024, 256 },
  106. { "CommandSet", 820, 16 },
  107. { "DisplayString", 32, 32 },
  108. { "WebBrowserURL", 16, 16 },
  109. { "Drawable", 4096, 32 },
  110. { "Image", 2048, 32 },
  111. { "ParticlePool", 1400, 1024 },
  112. { "ParticleSystemTemplatePool", 1100, 32 },
  113. { "ParticleSystemPool", 1024, 32 },
  114. { "TerrainRoadType", 100, 32, },
  115. { "WindowLayoutPool", 32, 32 },
  116. { "AnimatedParticleSysBoneClientUpdate", 16, 16 },
  117. { "SwayClientUpdate", 32, 32 },
  118. { "BeaconClientUpdate", 64, 32 },
  119. { "AIGroupPool", 64, 32 },
  120. { "AIDockMachinePool", 256, 32 },
  121. { "AIGuardMachinePool", 32, 32 },
  122. { "AIGuardRetaliateMachinePool", 32, 32 },
  123. { "AITNGuardMachinePool", 32, 32 },
  124. { "PathNodePool", 8192, 1024 },
  125. { "PathPool", 256, 16 },
  126. { "WorkOrder", 32, 32 },
  127. { "TeamInQueue", 32, 32 },
  128. { "AIPlayer", 12, 4 },
  129. { "AISkirmishPlayer", 8, 8 },
  130. { "AIStateMachine", 600, 32 },
  131. { "JetAIStateMachine", 64, 32 },
  132. { "HeliAIStateMachine", 64, 32 },
  133. { "AIAttackMoveStateMachine", 2048, 32 },
  134. { "AIAttackThenIdleStateMachine", 512, 32 },
  135. { "AttackStateMachine", 512, 32 },
  136. { "CrateTemplate", 32, 32 },
  137. { "ExperienceTrackerPool", 2048, 512 },
  138. { "FiringTrackerPool", 4096, 256 },
  139. { "ObjectRepulsorHelper", 1024, 256 },
  140. { "ObjectSMCHelperPool", 2048, 256 },
  141. { "ObjectWeaponStatusHelperPool", 4096, 256 },
  142. { "ObjectDefectionHelperPool", 2048, 256 },
  143. { "StatusDamageHelper", 1500, 256 },
  144. { "SubdualDamageHelper", 1500, 256 },
  145. { "TempWeaponBonusHelper", 4096, 256 },
  146. { "Locomotor", 2048, 32 },
  147. { "LocomotorTemplate", 192, 32 },
  148. { "ObjectPool", 1500, 256 },
  149. { "SimpleObjectIteratorPool", 32, 32 },
  150. { "SimpleObjectIteratorClumpPool", 4096, 32 },
  151. { "PartitionDataPool", 2048, 512 },
  152. { "BuildEntry", 32, 32 },
  153. { "Weapon", 4096, 32 },
  154. { "WeaponTemplate", 360, 32 },
  155. { "AIUpdateInterface", 600, 32 },
  156. { "ActiveBody", 1024, 32 },
  157. { "ActiveShroudUpgrade", 32, 32 },
  158. { "AssistedTargetingUpdate", 32, 32 },
  159. { "AudioEventInfo", 4096, 64 },
  160. { "AudioRequest", 256, 8 },
  161. { "AutoHealBehavior", 1024, 256 },
  162. { "WeaponBonusUpdate", 16, 16 },
  163. { "GrantStealthBehavior", 4096, 32 },
  164. { "NeutronBlastBehavior", 4096, 32 },
  165. { "CountermeasuresBehavior", 256, 32 },
  166. { "BaseRegenerateUpdate", 128, 32 },
  167. { "BoneFXDamage", 64, 32 },
  168. { "BoneFXUpdate", 64, 32 },
  169. { "BridgeBehavior", 4, 4 },
  170. { "BridgeTowerBehavior", 32, 32 },
  171. { "BridgeScaffoldBehavior", 32, 32 },
  172. { "CaveContain", 16, 16 },
  173. { "HealContain", 32, 32 },
  174. { "CreateCrateDie", 256, 128 },
  175. { "CreateObjectDie", 1024, 32 },
  176. { "EjectPilotDie", 1024, 32 },
  177. { "CrushDie", 1024, 32 },
  178. { "DamDie", 8, 8 },
  179. { "DeliverPayloadStateMachine", 32, 32 },
  180. { "DeliverPayloadAIUpdate", 32, 32 },
  181. { "DeletionUpdate", 128, 32 },
  182. { "SmartBombTargetHomingUpdate", 8, 8 },
  183. { "DynamicAudioEventInfo", 16, 256 }, // Note: some levels have none, some have lots. Since all are allocated at level load time, we can set this low for the levels with none.
  184. { "HackInternetStateMachine", 32, 32 },
  185. { "HackInternetAIUpdate", 32, 32 },
  186. { "MissileAIUpdate", 512, 32 },
  187. { "DumbProjectileBehavior", 64, 32 },
  188. { "DestroyDie", 1024, 32 },
  189. { "UpgradeDie", 128, 32 },
  190. { "KeepObjectDie", 128, 32 },
  191. { "DozerAIUpdate", 32, 32 },
  192. { "DynamicGeometryInfoUpdate", 16, 16 },
  193. { "DynamicShroudClearingRangeUpdate", 128, 16 },
  194. { "FXListDie", 1024, 32 },
  195. { "FireSpreadUpdate", 2048, 128 },
  196. { "FirestormDynamicGeometryInfoUpdate", 16, 16 },
  197. { "FireWeaponCollide", 2048, 32 },
  198. { "FireWeaponUpdate", 32, 32 },
  199. { "FlammableUpdate", 512, 256 },
  200. { "FloatUpdate", 512, 128 },
  201. { "TensileFormationUpdate", 256, 32 },
  202. { "GarrisonContain", 256, 32 },
  203. { "HealCrateCollide", 32, 32 },
  204. { "HeightDieUpdate", 32, 32 },
  205. { "FireWeaponWhenDamagedBehavior", 32, 32 },
  206. { "FireWeaponWhenDeadBehavior", 128, 64 },
  207. { "GenerateMinefieldBehavior", 32, 32 },
  208. { "HelicopterSlowDeathBehavior", 64, 32 },
  209. { "ParkingPlaceBehavior", 32, 32 },
  210. { "FlightDeckBehavior", 8, 8 },
  211. #ifdef ALLOW_SURRENDER
  212. { "POWTruckAIUpdate", 32, 32, },
  213. { "POWTruckBehavior", 32, 32, },
  214. { "PrisonBehavior", 32, 32 },
  215. { "PrisonVisual", 32, 32 },
  216. { "PropagandaCenterBehavior", 16, 16 },
  217. #endif
  218. { "PropagandaTowerBehavior", 16, 16 },
  219. { "BunkerBusterBehavior", 16, 16 },
  220. { "ObjectTracker", 128, 32 },
  221. { "OCLUpdate", 16, 16 },
  222. { "BodyParticleSystem", 196, 64 },
  223. { "HighlanderBody", 2048, 128 },
  224. { "UndeadBody", 32, 32 },
  225. { "HordeUpdate", 128, 32 },
  226. { "ImmortalBody", 128, 256 },
  227. { "InactiveBody", 2048, 32 },
  228. { "InstantDeathBehavior", 512, 32 },
  229. { "LaserUpdate", 32, 32 },
  230. { "PointDefenseLaserUpdate", 32, 32 },
  231. { "CleanupHazardUpdate", 32, 32 },
  232. { "AutoFindHealingUpdate", 256, 32 },
  233. { "CommandButtonHuntUpdate", 512, 8 },
  234. { "PilotFindVehicleUpdate", 256, 32 },
  235. { "DemoTrapUpdate", 32, 32 },
  236. { "ParticleUplinkCannonUpdate", 16, 16 },
  237. { "SpectreGunshipUpdate", 8, 8 },
  238. { "SpectreGunshipDeploymentUpdate", 8, 8 },
  239. { "BaikonurLaunchPower", 4, 4 },
  240. { "RadiusDecalUpdate", 16, 16 },
  241. { "BattlePlanUpdate", 32, 32 },
  242. { "LifetimeUpdate", 32, 32 },
  243. { "LocomotorSetUpgrade", 512, 128 },
  244. { "LockWeaponCreate", 64, 128 },
  245. { "AutoDepositUpdate", 256, 32 },
  246. { "NeutronMissileUpdate", 512, 32 },
  247. { "MoneyCrateCollide", 48, 16 },
  248. { "NeutronMissileSlowDeathBehavior", 8, 8 },
  249. { "OpenContain", 128, 32 },
  250. { "OverchargeBehavior", 32, 32 },
  251. { "OverlordContain", 32, 32 },
  252. { "HelixContain", 32, 32 },
  253. { "ParachuteContain", 128, 32 },
  254. { "PhysicsBehavior", 600, 32 },
  255. { "PoisonedBehavior", 512, 64 },
  256. { "ProductionEntry", 32, 32 },
  257. { "ProductionUpdate", 256, 32 },
  258. { "ProjectileStreamUpdate", 32, 32 },
  259. { "ProneUpdate", 128, 32 },
  260. { "QueueProductionExitUpdate", 32, 32 },
  261. { "RadarUpdate", 16, 16 },
  262. { "RadarUpgrade", 16, 16 },
  263. { "AnimationSteeringUpdate", 1024, 32 },
  264. { "SupplyWarehouseCripplingBehavior", 16, 16 },
  265. { "CostModifierUpgrade", 32, 32 },
  266. { "CashBountyPower", 32, 32 },
  267. { "CleanupAreaPower", 32, 32 },
  268. { "ObjectCreationUpgrade", 196, 32 },
  269. { "MinefieldBehavior", 256, 32 },
  270. { "JetSlowDeathBehavior", 64, 32 },
  271. { "BattleBusSlowDeathBehavior", 64, 32 },
  272. { "RebuildHoleBehavior", 64, 32 },
  273. { "RebuildHoleExposeDie", 64, 32 },
  274. { "RepairDockUpdate", 32, 32 },
  275. #ifdef ALLOW_SURRENDER
  276. { "PrisonDockUpdate", 32, 32 },
  277. #endif
  278. { "RailedTransportDockUpdate", 16, 16 },
  279. { "RailedTransportAIUpdate", 16, 16 },
  280. { "RailedTransportContain", 16, 16 },
  281. { "RailroadBehavior", 16, 16 },
  282. { "SalvageCrateCollide", 32, 32 },
  283. { "ShroudCrateCollide", 32, 32 },
  284. { "SlavedUpdate", 64, 32 },
  285. { "SlowDeathBehavior", 1400, 256 },
  286. { "SpyVisionUpdate", 16, 16 },
  287. { "DefaultProductionExitUpdate", 32, 32 },
  288. { "SpawnPointProductionExitUpdate", 32, 32 },
  289. { "SpawnBehavior", 32, 32 },
  290. { "SpecialPowerCompletionDie", 32, 32 },
  291. { "SpecialPowerCreate", 32, 32 },
  292. { "PreorderCreate", 32, 32 },
  293. { "SpecialAbility", 512, 32 },
  294. { "SpecialAbilityUpdate", 512, 32 },
  295. { "MissileLauncherBuildingUpdate", 32, 32 },
  296. { "SquishCollide", 512, 32 },
  297. { "StructureBody", 512, 64 },
  298. { "HiveStructureBody", 64, 32 }, //Stinger sites
  299. { "StructureCollapseUpdate", 32, 32 },
  300. { "StructureToppleUpdate", 32, 32 },
  301. { "SupplyCenterCreate", 32, 32 },
  302. { "SupplyCenterDockUpdate", 32, 32 },
  303. { "SupplyCenterProductionExitUpdate", 32, 32 },
  304. { "SupplyTruckStateMachine", 256, 32 },
  305. { "SupplyTruckAIUpdate", 32, 32 },
  306. { "SupplyWarehouseCreate", 48, 16 },
  307. { "SupplyWarehouseDockUpdate", 48, 16 },
  308. { "EnemyNearUpdate", 1024, 32 },
  309. { "TechBuildingBehavior", 32, 32 },
  310. { "ToppleUpdate", 256, 128 },
  311. { "TransitionDamageFX", 384, 128 },
  312. { "TransportAIUpdate", 64, 32 },
  313. { "TransportContain", 128, 32 },
  314. { "RiderChangeContain", 128, 32 },
  315. { "InternetHackContain", 16, 16 },
  316. { "TunnelContain", 8, 8 },
  317. { "TunnelContainDie", 32, 32 },
  318. { "TunnelCreate", 32, 32 },
  319. { "TurretAI", 256, 32 },
  320. { "TurretStateMachine", 128, 32 },
  321. { "TurretSwapUpgrade", 512, 128 },
  322. { "UnitCrateCollide", 32, 32 },
  323. { "UnpauseSpecialPowerUpgrade", 32, 32 },
  324. { "VeterancyCrateCollide", 32, 32 },
  325. { "VeterancyGainCreate", 512, 128 },
  326. { "ConvertToCarBombCrateCollide", 256, 128 },
  327. { "ConvertToHijackedVehicleCrateCollide", 256, 128 },
  328. { "SabotageCommandCenterCrateCollide", 256, 128 },
  329. { "SabotageFakeBuildingCrateCollide", 256, 128 },
  330. { "SabotageInternetCenterCrateCollide", 256, 128 },
  331. { "SabotageMilitaryFactoryCrateCollide", 256, 128 },
  332. { "SabotagePowerPlantCrateCollide", 256, 128 },
  333. { "SabotageSuperweaponCrateCollide", 256, 128 },
  334. { "SabotageSupplyCenterCrateCollide", 256, 128 },
  335. { "SabotageSupplyDropzoneCrateCollide", 256, 128 },
  336. { "JetAIUpdate", 64, 32 },
  337. { "ChinookAIUpdate", 32, 32 },
  338. { "WanderAIUpdate", 32, 32 },
  339. { "WaveGuideUpdate", 16, 16 },
  340. { "WeaponBonusUpgrade", 512, 128 },
  341. { "WeaponSetUpgrade", 512, 128 },
  342. { "ArmorUpgrade", 512, 128 },
  343. { "WorkerAIUpdate", 128, 128 },
  344. { "WorkerStateMachine", 128, 128 },
  345. { "ChinookAIStateMachine", 32, 32 },
  346. { "DeployStyleAIUpdate", 32, 32 },
  347. { "AssaultTransportAIUpdate", 64, 32 },
  348. { "StreamingArchiveFile", 8, 8 },
  349. { "DozerActionStateMachine", 256, 32 },
  350. { "DozerPrimaryStateMachine", 256, 32 },
  351. { "W3DDisplayString", 1400, 128 },
  352. { "W3DDefaultDraw", 1024, 128 },
  353. { "W3DDebrisDraw", 128, 128 },
  354. { "W3DDependencyModelDraw", 64, 64 },
  355. { "W3DLaserDraw", 32, 32 },
  356. { "W3DModelDraw", 2048, 512 },
  357. { "W3DOverlordTankDraw", 64, 64 },
  358. { "W3DOverlordTruckDraw", 64, 64 },
  359. { "W3DOverlordAircraftDraw", 64, 64 },
  360. { "W3DPoliceCarDraw", 32, 32 },
  361. { "W3DProjectileStreamDraw", 32, 32 },
  362. { "W3DRopeDraw", 32, 32 },
  363. { "W3DScienceModelDraw", 32, 32 },
  364. { "W3DSupplyDraw", 40, 16 },
  365. { "W3DTankDraw", 256, 32 },
  366. { "W3DTreeDraw", 16, 16 },
  367. { "W3DPropDraw", 16, 16 },
  368. { "W3DTracerDraw", 64, 32 },
  369. { "W3DTruckDraw", 128, 32 },
  370. { "W3DTankTruckDraw", 32, 16 },
  371. { "W3DTreeTextureClass", 4, 4 },
  372. { "DefaultSpecialPower", 32, 32 },
  373. { "OCLSpecialPower", 96, 32 },
  374. { "FireWeaponPower", 32, 32 },
  375. #ifdef ALLOW_DEMORALIZE
  376. { "DemoralizeSpecialPower", 16, 16, },
  377. #endif
  378. { "CashHackSpecialPower", 32, 32 },
  379. { "CommandSetUpgrade", 32, 32 },
  380. { "PassengersFireUpgrade", 32, 32 },
  381. { "GrantUpgradeCreate", 256, 32 },
  382. { "GrantScienceUpgrade", 256, 32 },
  383. { "ReplaceObjectUpgrade", 32, 32 },
  384. { "ModelConditionUpgrade", 32, 32 },
  385. { "SpyVisionSpecialPower", 256, 32 },
  386. { "StealthDetectorUpdate", 256, 32 },
  387. { "StealthUpdate", 512, 128 },
  388. { "StealthUpgrade", 256, 32 },
  389. { "StatusBitsUpgrade", 128, 128 },
  390. { "SubObjectsUpgrade", 128, 128 },
  391. { "ExperienceScalarUpgrade", 256, 128 },
  392. { "MaxHealthUpgrade", 128, 128 },
  393. { "WeaponBonusUpgrade", 128, 64 },
  394. { "StickyBombUpdate", 64, 32 },
  395. { "FireOCLAfterWeaponCooldownUpdate", 64, 32 },
  396. { "HijackerUpdate", 64, 32 },
  397. { "ChinaMinesUpgrade", 64, 32 },
  398. { "PowerPlantUpdate", 48, 16 },
  399. { "PowerPlantUpgrade", 48, 16 },
  400. { "DefectorSpecialPower", 16, 16 },
  401. { "CheckpointUpdate", 16, 16 },
  402. { "MobNexusContain", 128, 32 },
  403. { "MobMemberSlavedUpdate", 64, 32 },
  404. { "EMPUpdate", 64, 32 },
  405. { "LeafletDropBehavior", 64, 32 },
  406. { "Overridable", 32, 32 },
  407. { "W3DGameWindow", 700, 256 },
  408. { "SuccessState", 32, 32 },
  409. { "FailureState", 32, 32 },
  410. { "ContinueState", 32, 32 },
  411. { "SleepState", 32, 32 },
  412. { "AIDockWaitForClearanceState", 256, 32 },
  413. { "AIDockProcessDockState", 256, 32 },
  414. { "AIGuardInnerState", 32, 32 },
  415. { "AIGuardIdleState", 32, 32 },
  416. { "AIGuardOuterState", 32, 32 },
  417. { "AIGuardReturnState", 32, 32 },
  418. { "AIGuardPickUpCrateState", 32, 32 },
  419. { "AIGuardAttackAggressorState", 32, 32 },
  420. { "AIGuardRetaliateInnerState", 32, 32 },
  421. { "AIGuardRetaliateIdleState", 32, 32 },
  422. { "AIGuardRetaliateOuterState", 32, 32 },
  423. { "AIGuardRetaliateReturnState", 32, 32 },
  424. { "AIGuardRetaliatePickUpCrateState", 32, 32 },
  425. { "AIGuardRetaliateAttackAggressorState", 32, 32 },
  426. { "AITNGuardInnerState", 32, 32 },
  427. { "AITNGuardIdleState", 32, 32 },
  428. { "AITNGuardOuterState", 32, 32 },
  429. { "AITNGuardReturnState", 32, 32 },
  430. { "AITNGuardPickUpCrateState", 32, 32 },
  431. { "AITNGuardAttackAggressorState", 32, 32 },
  432. { "AIIdleState", 2400, 32 },
  433. { "AIRappelState", 600, 32 },
  434. { "AIBusyState", 600, 32 },
  435. { "AIWaitState", 600, 32 },
  436. { "AIAttackState", 4096, 32 },
  437. { "AIAttackSquadState", 600, 32 },
  438. { "AIDeadState", 600, 32 },
  439. { "AIDockState", 600, 32 },
  440. { "AIExitState", 600, 32 },
  441. { "AIExitInstantlyState", 600, 32 },
  442. { "AIGuardState", 600, 32 },
  443. { "AIGuardRetaliateState", 600, 32 },
  444. { "AITunnelNetworkGuardState", 600, 32 },
  445. { "AIHuntState", 600, 32 },
  446. { "AIAttackAreaState", 600, 32 },
  447. { "AIFaceState", 1200, 32 },
  448. { "ApproachState", 600, 32 },
  449. { "DeliveringState", 600, 32 },
  450. { "ConsiderNewApproachState", 600, 32 },
  451. { "RecoverFromOffMapState", 600, 32 },
  452. { "HeadOffMapState", 600, 32 },
  453. { "CleanUpState", 600, 32 },
  454. { "HackInternetState", 600, 32 },
  455. { "PackingState", 600, 32 },
  456. { "UnpackingState", 600, 32 },
  457. { "SupplyTruckWantsToPickUpOrDeliverBoxesState", 600, 32 },
  458. { "RegroupingState", 600, 32 },
  459. { "DockingState", 600, 32 },
  460. { "ChinookEvacuateState", 32, 32 },
  461. { "ChinookHeadOffMapState", 32, 32 },
  462. { "ChinookTakeoffOrLandingState", 32, 32 },
  463. { "ChinookCombatDropState", 32, 32 },
  464. { "DozerActionPickActionPosState", 256, 32 },
  465. { "DozerActionMoveToActionPosState", 256, 32 },
  466. { "DozerActionDoActionState", 256, 32 },
  467. { "DozerPrimaryIdleState", 256, 32 },
  468. { "DozerActionState", 256, 32 },
  469. { "DozerPrimaryGoingHomeState", 256, 32 },
  470. { "JetAwaitingRunwayState", 64, 32 },
  471. { "JetOrHeliCirclingDeadAirfieldState", 64, 32 },
  472. { "HeliTakeoffOrLandingState", 64, 32 },
  473. { "JetOrHeliParkOrientState", 64, 32 },
  474. { "JetOrHeliReloadAmmoState", 64, 32 },
  475. { "SupplyTruckBusyState", 600, 32 },
  476. { "SupplyTruckIdleState", 600, 32 },
  477. { "ActAsDozerState", 600, 32 },
  478. { "ActAsSupplyTruckState", 600, 32 },
  479. { "AIDockApproachState", 256, 32 },
  480. { "AIDockAdvancePositionState", 256, 32 },
  481. { "AIDockMoveToEntryState", 256, 32 },
  482. { "AIDockMoveToDockState", 256, 32 },
  483. { "AIDockMoveToExitState", 256, 32 },
  484. { "AIDockMoveToRallyState", 256, 32 },
  485. { "AIMoveToState", 600, 32 },
  486. { "AIMoveOutOfTheWayState", 600, 32 },
  487. { "AIMoveAndTightenState", 600, 32 },
  488. { "AIMoveAwayFromRepulsorsState", 600, 32 },
  489. { "AIAttackApproachTargetState", 96, 32 },
  490. { "AIAttackPursueTargetState", 96, 32 },
  491. { "AIAttackAimAtTargetState", 96, 32 },
  492. { "AIAttackFireWeaponState", 256, 32 },
  493. { "AIPickUpCrateState", 4096, 32 },
  494. { "AIFollowWaypointPathState", 1200, 32 },
  495. { "AIFollowWaypointPathExactState", 1200, 32 },
  496. { "AIWanderInPlaceState", 600, 32 },
  497. { "AIFollowPathState", 1200, 32 },
  498. { "AIMoveAndEvacuateState", 1200, 32 },
  499. { "AIMoveAndDeleteState", 600, 32 },
  500. { "AIEnterState", 600, 32 },
  501. { "JetOrHeliReturningToDeadAirfieldState", 64, 32 },
  502. { "JetOrHeliReturnForLandingState", 64, 32 },
  503. { "TurretAIIdleState", 600, 32 },
  504. { "TurretAIIdleScanState", 600, 32 },
  505. { "TurretAIAimTurretState", 600, 32 },
  506. { "TurretAIRecenterTurretState", 600, 32 },
  507. { "TurretAIHoldTurretState", 600, 32 },
  508. { "JetOrHeliTaxiState", 64, 32 },
  509. { "JetTakeoffOrLandingState", 64, 32 },
  510. { "JetPauseBeforeTakeoffState", 64, 32 },
  511. { "AIAttackMoveToState", 600, 32 },
  512. { "AIAttackFollowWaypointPathState", 1200, 32 },
  513. { "AIWanderState", 600, 32 },
  514. { "AIPanicState", 600, 32 },
  515. { "ChinookMoveToBldgState", 32, 32 },
  516. { "ChinookRecordCreationState", 32, 32 },
  517. { "ScienceInfo", 96, 32 },
  518. { "RankInfo", 32, 32 },
  519. { "FireWeaponNugget", 32, 32 },
  520. { "AttackNugget", 32, 32 },
  521. { "DeliverPayloadNugget", 48, 32 },
  522. { "ApplyRandomForceNugget", 32, 32 },
  523. { "GenericObjectCreationNugget", 632, 32 },
  524. { "SoundFXNugget", 320, 32 },
  525. { "TracerFXNugget", 32, 32 },
  526. { "RayEffectFXNugget", 32, 32 },
  527. { "LightPulseFXNugget", 68, 32 },
  528. { "ViewShakeFXNugget", 140, 32 },
  529. { "TerrainScorchFXNugget", 48, 32 },
  530. { "ParticleSystemFXNugget", 832, 32 },
  531. { "FXListAtBonePosFXNugget", 32, 32 },
  532. { "Squad", 256, 32 },
  533. { "BuildListInfo", 400, 64 },
  534. { "ScriptGroup", 128, 32 },
  535. { "OrCondition", 1024, 256 },
  536. { "ScriptAction", 2600, 512 },
  537. { "Script", 1024, 256 },
  538. { "Parameter", 8192, 1024 },
  539. { "Condition", 2048, 256 },
  540. { "Template", 32, 32 },
  541. { "ScriptList", 32, 32 },
  542. { "AttackPriorityInfo", 32, 32 },
  543. { "SequentialScript", 32, 32 },
  544. { "Win32LocalFile", 1024, 256 },
  545. { "RAMFile", 32, 32 },
  546. { "BattlePlanBonuses", 32, 32 },
  547. { "KindOfPercentProductionChange", 32, 32 },
  548. { "UserParser", 4096, 256 },
  549. { "XferBlockData", 32, 32 },
  550. { "EvaCheckInfo", 52, 16 },
  551. { "SuperweaponInfo", 32, 32 },
  552. { "NamedTimerInfo", 32, 32 },
  553. { "PopupMessageData", 32, 32 },
  554. { "FloatingTextData", 32, 32 },
  555. { "MapObject", 5000, 1024 },
  556. { "Waypoint", 1024, 32 },
  557. { "PolygonTrigger", 64, 64 },
  558. { "Bridge", 32, 32 },
  559. { "Mapping", 384, 64 },
  560. { "OutputChunk", 32, 32 },
  561. { "InputChunk", 32, 32 },
  562. { "AnimateWindow", 32, 32 },
  563. { "GameFont", 32, 32 },
  564. { "NetCommandRef", 256, 32 },
  565. { "GameMessageArgument", 1024, 256 },
  566. { "GameMessageParserArgumentType", 32, 32 },
  567. { "GameMessageParser", 32, 32 },
  568. { "WeaponBonusSet", 96, 32 },
  569. { "Campaign", 32, 32 },
  570. { "Mission", 88, 32 },
  571. { "ModalWindow", 32, 32 },
  572. { "NetPacket", 32, 32 },
  573. { "AISideInfo", 32, 32 },
  574. { "AISideBuildList", 32, 32 },
  575. { "MetaMapRec", 256, 32 },
  576. { "TransportStatus", 32, 32 },
  577. { "Anim2DTemplate", 32, 32 },
  578. { "ObjectTypes", 32, 32 },
  579. { "NetCommandList", 512, 32 },
  580. { "TurretAIData", 256, 32 },
  581. { "NetCommandMsg", 32, 32 },
  582. { "NetGameCommandMsg", 64, 32 },
  583. { "NetAckBothCommandMsg", 32, 32 },
  584. { "NetAckStage1CommandMsg", 32, 32 },
  585. { "NetAckStage2CommandMsg", 32, 32 },
  586. { "NetFrameCommandMsg", 32, 32 },
  587. { "NetPlayerLeaveCommandMsg", 32, 32 },
  588. { "NetRunAheadMetricsCommandMsg", 32, 32 },
  589. { "NetRunAheadCommandMsg", 32, 32 },
  590. { "NetDestroyPlayerCommandMsg", 32, 32 },
  591. { "NetDisconnectFrameCommandMsg", 32, 32 },
  592. { "NetDisconnectScreenOffCommandMsg", 32, 32 },
  593. { "NetFrameResendRequestCommandMsg", 32, 32 },
  594. { "NetKeepAliveCommandMsg", 32, 32 },
  595. { "NetDisconnectKeepAliveCommandMsg", 32, 32 },
  596. { "NetDisconnectPlayerCommandMsg", 32, 32 },
  597. { "NetPacketRouterQueryCommandMsg", 32, 32 },
  598. { "NetPacketRouterAckCommandMsg", 32, 32 },
  599. { "NetDisconnectChatCommandMsg", 32, 32 },
  600. { "NetChatCommandMsg", 32, 32 },
  601. { "NetDisconnectVoteCommandMsg", 32, 32 },
  602. { "NetProgressCommandMsg", 32, 32 },
  603. { "NetWrapperCommandMsg", 32, 32 },
  604. { "NetFileCommandMsg", 32, 32 },
  605. { "NetFileAnnounceCommandMsg", 32, 32 },
  606. { "NetFileProgressCommandMsg", 32, 32 },
  607. { "NetCommandWrapperListNode", 32, 32 },
  608. { "NetCommandWrapperList", 32, 32 },
  609. { "Connection", 32, 32 },
  610. { "User", 32, 32 },
  611. { "FrameDataManager", 32, 32 },
  612. { "DrawableIconInfo", 32, 32 },
  613. { "TintEnvelope", 128, 32 },
  614. { "DynamicAudioEventRTS", 4000, 256 },
  615. { "DrawableLocoInfo", 128, 32 },
  616. { "W3DPrototypeClass", 512, 256 },
  617. { "EnumeratedIP", 32, 32 },
  618. { "WaterTransparencySetting", 4, 4 },
  619. { "WeatherSetting", 4, 4 },
  620. // W3D pools!
  621. { "BoxPrototypeClass", 128, 128 },
  622. { "SpherePrototypeClass", 32, 32 },
  623. { "SoundRenderObjPrototypeClass", 32, 32 },
  624. { "RingPrototypeClass", 32, 32 },
  625. { "PrimitivePrototypeClass", 8192, 32 },
  626. { "HModelPrototypeClass", 256, 32 },
  627. { "ParticleEmitterPrototypeClass", 32, 32 },
  628. { "NullPrototypeClass", 32, 32 },
  629. { "HLodPrototypeClass", 700, 128 },
  630. { "HLodDefClass", 700, 128 },
  631. { "DistLODPrototypeClass", 32, 32 },
  632. { "DazzlePrototypeClass", 32, 32 },
  633. { "CollectionPrototypeClass", 32, 32 },
  634. { "BoxPrototypeClass", 256, 32 },
  635. { "AggregatePrototypeClass", 32, 32 },
  636. { "OBBoxRenderObjClass", 512, 128 },
  637. { "AABoxRenderObjClass", 32, 32 },
  638. { "VertexMaterialClass", 6000, 2048 },
  639. { "TextureClass", 1200, 256 },
  640. { "CloudMapTerrainTextureClass", 4, 4 },
  641. { "ScorchTextureClass", 4, 4 },
  642. { "LightMapTerrainTextureClass", 4, 4 },
  643. { "AlphaEdgeTextureClass", 4, 4 },
  644. { "AlphaTerrainTextureClass", 4, 4 },
  645. { "TerrainTextureClass", 4, 4 },
  646. { "MeshClass", 14000, 2000 },
  647. { "HTreeClass", 2048, 512 },
  648. { "HLodClass", 2048, 512 },
  649. { "MeshModelClass", 8192, 32 },
  650. { "ShareBufferClass", 32768, 1024 },
  651. { "AABTreeClass", 300, 128 },
  652. { "MotionChannelClass", 16384, 32 },
  653. { "BitChannelClass", 84, 32 },
  654. { "TimeCodedMotionChannelClass", 116, 32 },
  655. { "AdaptiveDeltaMotionChannelClass", 32, 32 },
  656. { "TimeCodedBitChannelClass", 32, 32 },
  657. { "UVBufferClass", 8192, 32 },
  658. { "TexBufferClass", 384, 128 },
  659. { "MatBufferClass", 256, 128 },
  660. { "MatrixMapperClass", 32, 32 },
  661. { "ScaleTextureMapperClass", 32, 32 },
  662. { "LinearOffsetTextureMapperClass", 96, 32 },
  663. { "GridTextureMapperClass", 32, 32 },
  664. { "RotateTextureMapperClass", 32, 32 },
  665. { "SineLinearOffsetTextureMapperClass", 32, 32 },
  666. { "StepLinearOffsetTextureMapperClass", 32, 32 },
  667. { "ZigZagLinearOffsetTextureMapperClass", 32, 32 },
  668. { "ClassicEnvironmentMapperClass", 32, 32 },
  669. { "EnvironmentMapperClass", 256, 32 },
  670. { "EdgeMapperClass", 32, 32 },
  671. { "WSClassicEnvironmentMapperClass", 32, 32 },
  672. { "WSEnvironmentMapperClass", 32, 32 },
  673. { "GridClassicEnvironmentMapperClass", 32, 32 },
  674. { "GridEnvironmentMapperClass", 32, 32 },
  675. { "ScreenMapperClass", 32, 32 },
  676. { "RandomTextureMapperClass", 32, 32 },
  677. { "BumpEnvTextureMapperClass", 32, 32 },
  678. { "MeshLoadContextClass", 4, 4 },
  679. { "MaterialInfoClass", 8192, 32 },
  680. { "MeshMatDescClass", 8192, 32 },
  681. { "TextureLoadTaskClass", 256, 32 },
  682. { "SortingNodeStruct", 288, 32 },
  683. { "ProxyArrayClass", 32, 32 },
  684. { "Line3DClass", 8, 8 },
  685. { "Render2DClass", 64, 32 },
  686. { "SurfaceClass", 128, 32 },
  687. { "FontCharsClassCharDataStruct", 1024, 32 },
  688. { "FontCharsBuffer", 16, 4 },
  689. { "FVFInfoClass", 152, 64 },
  690. { "TerrainTracksRenderObjClass", 128, 32 },
  691. { "DynamicIBAccessClass", 32, 32 },
  692. { "DX8IndexBufferClass", 128, 32 },
  693. { "SortingIndexBufferClass", 32, 32 },
  694. { "DX8VertexBufferClass", 128, 32 },
  695. { "SortingVertexBufferClass", 32, 32 },
  696. { "DynD3DMATERIAL8", 8192, 32 },
  697. { "DynamicMatrix3D", 512, 32 },
  698. { "MeshGeometryClass", 32, 32 },
  699. { "DynamicMeshModel", 32, 32 },
  700. { "GapFillerClass", 32, 32 },
  701. { "FontCharsClass", 64, 32 },
  702. { "ThumbnailManagerClass", 32, 32},
  703. { "SmudgeSet", 32, 32},
  704. { "Smudge", 128, 32},
  705. { 0, 0, 0 }
  706. };
  707. //-----------------------------------------------------------------------------
  708. void userMemoryAdjustPoolSize(const char *poolName, Int& initialAllocationCount, Int& overflowAllocationCount)
  709. {
  710. if (initialAllocationCount > 0)
  711. return;
  712. for (const PoolSizeRec* p = sizes; p->name != NULL; ++p)
  713. {
  714. if (strcmp(p->name, poolName) == 0)
  715. {
  716. initialAllocationCount = p->initial;
  717. overflowAllocationCount = p->overflow;
  718. return;
  719. }
  720. }
  721. DEBUG_CRASH(("Initial size for pool %s not found -- you should add it to MemoryInit.cpp\n",poolName));
  722. }
  723. //-----------------------------------------------------------------------------
  724. static Int roundUpMemBound(Int i)
  725. {
  726. const int MEM_BOUND_ALIGNMENT = 4;
  727. if (i < MEM_BOUND_ALIGNMENT)
  728. return MEM_BOUND_ALIGNMENT;
  729. else
  730. return (i + (MEM_BOUND_ALIGNMENT-1)) & ~(MEM_BOUND_ALIGNMENT-1);
  731. }
  732. //-----------------------------------------------------------------------------
  733. void userMemoryManagerInitPools()
  734. {
  735. // note that we MUST use stdio stuff here, and not the normal game file system
  736. // (with bigfile support, etc), because that relies on memory pools, which
  737. // aren't yet initialized properly! so rely ONLY on straight stdio stuff here.
  738. // (not even AsciiString. thanks.)
  739. // since we're called prior to main, the cur dir might not be what
  740. // we expect. so do it the hard way.
  741. char buf[_MAX_PATH];
  742. ::GetModuleFileName(NULL, buf, sizeof(buf));
  743. char* pEnd = buf + strlen(buf);
  744. while (pEnd != buf)
  745. {
  746. if (*pEnd == '\\')
  747. {
  748. *pEnd = 0;
  749. break;
  750. }
  751. --pEnd;
  752. }
  753. strcat(buf, "\\Data\\INI\\MemoryPools.ini");
  754. FILE* fp = fopen(buf, "r");
  755. if (fp)
  756. {
  757. char poolName[256];
  758. int initial, overflow;
  759. while (fgets(buf, _MAX_PATH, fp))
  760. {
  761. if (buf[0] == ';')
  762. continue;
  763. if (sscanf(buf, "%s %d %d", poolName, &initial, &overflow ) == 3)
  764. {
  765. for (PoolSizeRec* p = sizes; p->name != NULL; ++p)
  766. {
  767. if (stricmp(p->name, poolName) == 0)
  768. {
  769. // currently, these must be multiples of 4. so round up.
  770. p->initial = roundUpMemBound(initial);
  771. p->overflow = roundUpMemBound(overflow);
  772. break; // from for-p
  773. }
  774. }
  775. }
  776. }
  777. fclose(fp);
  778. }
  779. }