MemoryInit.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. /*
  2. ** Command & Conquer Generals(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, 65536, 1024 },
  59. { "dmaPool_32", 32, 150000, 1024 },
  60. { "dmaPool_64", 64, 60000, 1024 },
  61. { "dmaPool_128", 128, 32768, 1024 },
  62. { "dmaPool_256", 256, 8192, 1024 },
  63. { "dmaPool_512", 512, 8192, 1024 },
  64. { "dmaPool_1024", 1024, 24000, 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", 4096, 32 },
  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", 64, 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", 1200, 32 },
  101. { "TunnelTracker", 16, 16 },
  102. { "Upgrade", 16, 16 },
  103. { "UpgradeTemplate", 128, 16 },
  104. { "Anim2D", 32, 32 },
  105. { "CommandButton", 300, 16 },
  106. { "CommandSet", 256, 16 },
  107. { "DisplayString", 32, 32 },
  108. { "WebBrowserURL", 16, 16 },
  109. { "Drawable", 4096, 32 },
  110. { "Image", 2048, 32 },
  111. { "ParticlePool", 4096, 256 },
  112. { "ParticleSystemTemplatePool", 768, 32 },
  113. { "ParticleSystemPool", 1024, 32 },
  114. { "TerrainRoadType", 64, 64, },
  115. { "WindowLayoutPool", 32, 32 },
  116. { "AnimatedParticleSysBoneClientUpdate", 16, 16 },
  117. { "SwayClientUpdate", 4096, 32 },
  118. { "BeaconClientUpdate", 64, 32 },
  119. { "AIGroupPool", 64, 32 },
  120. { "AIDockMachinePool", 256, 32 },
  121. { "AIGuardMachinePool", 32, 32 },
  122. { "AITNGuardMachinePool", 32, 32 },
  123. { "PathNodePool", 8192, 1024 },
  124. { "PathPool", 256, 16 },
  125. { "WorkOrder", 32, 32 },
  126. { "TeamInQueue", 32, 32 },
  127. { "AIPlayer", 8, 8 },
  128. { "AISkirmishPlayer", 8, 8 },
  129. { "AIStateMachine", 600, 32 },
  130. { "JetAIStateMachine", 64, 32 },
  131. { "HeliAIStateMachine", 64, 32 },
  132. { "AIAttackMoveStateMachine", 2048, 32 },
  133. { "AIAttackThenIdleStateMachine", 512, 32 },
  134. { "AttackStateMachine", 512, 32 },
  135. { "CrateTemplate", 32, 32 },
  136. { "ExperienceTrackerPool", 4096, 256 },
  137. { "FiringTrackerPool", 4096, 256 },
  138. { "ObjectRepulsorHelper", 1024, 256 },
  139. { "ObjectSMCHelperPool", 4096, 256 },
  140. { "ObjectWeaponStatusHelperPool", 4096, 256 },
  141. { "ObjectDefectionHelperPool", 4096, 256 },
  142. { "Locomotor", 2048, 32 },
  143. { "LocomotorTemplate", 128, 32 },
  144. { "ObjectPool", 4096, 32 },
  145. { "SimpleObjectIteratorPool", 32, 32 },
  146. { "SimpleObjectIteratorClumpPool", 4096, 32 },
  147. { "PartitionDataPool", 4096, 32 },
  148. { "BuildEntry", 32, 32 },
  149. { "Weapon", 4096, 32 },
  150. { "WeaponTemplate", 192, 32 },
  151. { "AIUpdateInterface", 600, 32 },
  152. { "ActiveBody", 1024, 32 },
  153. { "ActiveShroudUpgrade", 32, 32 },
  154. { "AssistedTargetingUpdate", 32, 32 },
  155. { "AudioEventInfo", 1200, 64 },
  156. { "AudioRequest", 256, 8 },
  157. { "AutoHealBehavior", 4096, 32 },
  158. { "BaseRegenerateUpdate", 64, 32 },
  159. { "BoneFXDamage", 64, 32 },
  160. { "BoneFXUpdate", 64, 32 },
  161. { "BridgeBehavior", 32, 32 },
  162. { "BridgeTowerBehavior", 32, 32 },
  163. { "BridgeScaffoldBehavior", 32, 32 },
  164. { "CaveContain", 16, 16 },
  165. { "HealContain", 32, 32 },
  166. { "CreateCrateDie", 256, 128 },
  167. { "CreateObjectDie", 1024, 32 },
  168. { "EjectPilotDie", 1024, 32 },
  169. { "CrushDie", 1024, 32 },
  170. { "DamDie", 8, 8 },
  171. { "DelayedUpgrade", 32, 32 },
  172. { "DelayedWeaponSetUpgradeUpdate", 32, 32 },
  173. { "DeliverPayloadStateMachine", 32, 32 },
  174. { "DeliverPayloadAIUpdate", 32, 32 },
  175. { "DeletionUpdate", 128, 32 },
  176. { "HackInternetStateMachine", 32, 32 },
  177. { "HackInternetAIUpdate", 32, 32 },
  178. { "MissileAIUpdate", 512, 32 },
  179. { "DumbProjectileBehavior", 64, 32 },
  180. { "DestroyDie", 1024, 32 },
  181. { "UpgradeDie", 128, 32 },
  182. { "KeepObjectDie", 128, 32 },
  183. { "DozerAIUpdate", 32, 32 },
  184. { "DynamicGeometryInfoUpdate", 16, 16 },
  185. { "DynamicShroudClearingRangeUpdate", 128, 16 },
  186. { "FXListDie", 1024, 32 },
  187. { "FireSpreadUpdate", 2048, 128 },
  188. { "FirestormDynamicGeometryInfoUpdate", 16, 16 },
  189. { "FireWeaponCollide", 2048, 32 },
  190. { "FireWeaponUpdate", 32, 32 },
  191. { "FlammableUpdate", 4096, 256 },
  192. { "FloatUpdate", 512, 128 },
  193. { "TensileFormationUpdate", 256, 32 },
  194. { "GarrisonContain", 256, 32 },
  195. { "HealCrateCollide", 32, 32 },
  196. { "HeightDieUpdate", 32, 32 },
  197. { "FireWeaponWhenDamagedBehavior", 32, 32 },
  198. { "FireWeaponWhenDeadBehavior", 64, 32 },
  199. { "GenerateMinefieldBehavior", 32, 32 },
  200. { "HelicopterSlowDeathBehavior", 64, 32 },
  201. { "ParkingPlaceBehavior", 32, 32 },
  202. #ifdef ALLOW_SURRENDER
  203. { "POWTruckAIUpdate", 32, 32, },
  204. { "POWTruckBehavior", 32, 32, },
  205. { "PrisonBehavior", 32, 32 },
  206. { "PrisonVisual", 32, 32 },
  207. { "PropagandaCenterBehavior", 16, 16 },
  208. #endif
  209. { "PropagandaTowerBehavior", 16, 16 },
  210. { "ObjectTracker", 128, 32 },
  211. { "OCLUpdate", 16, 16 },
  212. { "BodyParticleSystem", 128, 64 },
  213. { "HighlanderBody", 2048, 128 },
  214. { "HordeUpdate", 128, 32 },
  215. { "ImmortalBody", 2048, 128 },
  216. { "InactiveBody", 2048, 32 },
  217. { "InstantDeathBehavior", 512, 32 },
  218. { "LaserUpdate", 32, 32 },
  219. { "PointDefenseLaserUpdate", 32, 32 },
  220. { "CleanupHazardUpdate", 32, 32 },
  221. { "AutoFindHealingUpdate", 256, 32 },
  222. { "CommandButtonHuntUpdate", 512, 8 },
  223. { "PilotFindVehicleUpdate", 256, 32 },
  224. { "DemoTrapUpdate", 32, 32 },
  225. { "ParticleUplinkCannonUpdate", 16, 16 },
  226. { "BaikonurLaunchPower", 4, 4 },
  227. { "RadiusDecalUpdate", 16, 16 },
  228. { "BattlePlanUpdate", 32, 32 },
  229. { "LifetimeUpdate", 256, 32 },
  230. { "LocomotorSetUpgrade", 512, 128 },
  231. { "AutoDepositUpdate", 256, 32 },
  232. { "NeutronMissileUpdate", 512, 32 },
  233. { "MoneyCrateCollide", 32, 32 },
  234. { "NeutronMissileSlowDeathBehavior", 8, 8 },
  235. { "OpenContain", 128, 32 },
  236. { "OverchargeBehavior", 32, 32 },
  237. { "OverlordContain", 32, 32 },
  238. { "ParachuteContain", 128, 32 },
  239. { "PhysicsBehavior", 600, 32 },
  240. { "PoisonedBehavior", 512, 64 },
  241. { "ProductionEntry", 32, 32 },
  242. { "ProductionUpdate", 256, 32 },
  243. { "ProjectileStreamUpdate", 32, 32 },
  244. { "ProneUpdate", 128, 32 },
  245. { "QueueProductionExitUpdate", 32, 32 },
  246. { "RadarUpdate", 16, 16 },
  247. { "RadarUpgrade", 16, 16 },
  248. { "SupplyWarehouseCripplingBehavior", 16, 16 },
  249. { "CostModifierUpgrade", 32, 32 },
  250. { "CashBountyPower", 32, 32 },
  251. { "CleanupAreaPower", 32, 32 },
  252. { "ObjectCreationUpgrade", 128, 32 },
  253. { "MinefieldBehavior", 256, 32 },
  254. { "JetSlowDeathBehavior", 64, 32 },
  255. { "RebuildHoleBehavior", 64, 32 },
  256. { "RebuildHoleExposeDie", 64, 32 },
  257. { "RepairDockUpdate", 32, 32 },
  258. #ifdef ALLOW_SURRENDER
  259. { "PrisonDockUpdate", 32, 32 },
  260. #endif
  261. { "RailedTransportDockUpdate", 16, 16 },
  262. { "RailedTransportAIUpdate", 16, 16 },
  263. { "RailedTransportContain", 16, 16 },
  264. { "RailroadBehavior", 16, 16 },
  265. { "SalvageCrateCollide", 32, 32 },
  266. { "ShroudCrateCollide", 32, 32 },
  267. { "SlavedUpdate", 64, 32 },
  268. { "SlowDeathBehavior", 4096, 32 },
  269. { "SpyVisionUpdate", 16, 16 },
  270. { "DefaultProductionExitUpdate", 32, 32 },
  271. { "SpawnPointProductionExitUpdate", 32, 32 },
  272. { "SpawnBehavior", 32, 32 },
  273. { "SpecialPowerCompletionDie", 32, 32 },
  274. { "SpecialPowerCreate", 32, 32 },
  275. { "PreorderCreate", 32, 32 },
  276. { "SpecialAbility", 512, 32 },
  277. { "SpecialAbilityUpdate", 512, 32 },
  278. { "MissileLauncherBuildingUpdate", 32, 32 },
  279. { "SquishCollide", 512, 32 },
  280. { "StructureBody", 512, 64 },
  281. { "HiveStructureBody", 64, 32 }, //Stinger sites
  282. { "StructureCollapseUpdate", 32, 32 },
  283. { "StructureToppleUpdate", 32, 32 },
  284. { "SupplyCenterCreate", 32, 32 },
  285. { "SupplyCenterDockUpdate", 32, 32 },
  286. { "SupplyCenterProductionExitUpdate", 32, 32 },
  287. { "SupplyTruckStateMachine", 256, 32 },
  288. { "SupplyTruckAIUpdate", 32, 32 },
  289. { "SupplyWarehouseCreate", 32, 32 },
  290. { "SupplyWarehouseDockUpdate", 32, 32 },
  291. { "EnemyNearUpdate", 1024, 32 },
  292. { "TechBuildingBehavior", 32, 32 },
  293. { "ToppleUpdate", 2048, 32 },
  294. { "TransitionDamageFX", 256, 32 },
  295. { "TransportAIUpdate", 64, 32 },
  296. { "TransportContain", 128, 32 },
  297. { "TunnelContain", 16, 16 },
  298. { "TunnelContainDie", 32, 32 },
  299. { "TunnelCreate", 32, 32 },
  300. { "TurretAI", 256, 32 },
  301. { "TurretStateMachine", 128, 32 },
  302. { "TurretSwapUpgrade", 512, 128 },
  303. { "UnitCrateCollide", 32, 32 },
  304. { "UnpauseSpecialPowerUpgrade", 32, 32 },
  305. { "VeterancyCrateCollide", 32, 32 },
  306. { "VeterancyGainCreate", 512, 128 },
  307. { "ConvertToCarBombCrateCollide", 32, 32 },
  308. { "ConvertToHijackedVehicleCrateCollide", 32, 32 },
  309. { "JetAIUpdate", 64, 32 },
  310. { "ChinookAIUpdate", 32, 32 },
  311. { "WanderAIUpdate", 32, 32 },
  312. { "WaveGuideUpdate", 16, 16 },
  313. { "WeaponBonusUpgrade", 512, 128 },
  314. { "WeaponSetUpgrade", 512, 128 },
  315. { "ArmorUpgrade", 512, 128 },
  316. { "WorkerAIUpdate", 128, 128 },
  317. { "WorkerStateMachine", 128, 128 },
  318. { "ChinookAIStateMachine", 32, 32 },
  319. { "DeployStyleAIUpdate", 32, 32 },
  320. { "AssaultTransportAIUpdate", 64, 32 },
  321. { "StreamingArchiveFile", 8, 8 },
  322. { "DozerActionStateMachine", 256, 32 },
  323. { "DozerPrimaryStateMachine", 256, 32 },
  324. { "W3DDisplayString", 1024, 128 },
  325. { "W3DDefaultDraw", 1024, 128 },
  326. { "W3DDebrisDraw", 1024, 128 },
  327. { "W3DDependencyModelDraw", 64, 64 },
  328. { "W3DLaserDraw", 32, 32 },
  329. { "W3DModelDraw", 4096, 128 },
  330. { "W3DOverlordTankDraw", 64, 64 },
  331. { "W3DPoliceCarDraw", 32, 32 },
  332. { "W3DProjectileStreamDraw", 32, 32 },
  333. { "W3DRopeDraw", 32, 32 },
  334. { "W3DScienceModelDraw", 32, 32 },
  335. { "W3DSupplyDraw", 32, 32 },
  336. { "W3DTankDraw", 256, 32 },
  337. { "W3DTracerDraw", 64, 32 },
  338. { "W3DTruckDraw", 128, 32 },
  339. { "W3DTankTruckDraw", 32, 16 },
  340. { "DefaultSpecialPower", 32, 32 },
  341. { "OCLSpecialPower", 32, 32 },
  342. #ifdef ALLOW_DEMORALIZE
  343. { "DemoralizeSpecialPower", 16, 16, },
  344. #endif
  345. { "CashHackSpecialPower", 32, 32 },
  346. { "CommandSetUpgrade", 32, 32 },
  347. { "GrantUpgradeCreate", 256, 32 },
  348. { "SpyVisionSpecialPower", 256, 32 },
  349. { "StealthDetectorUpdate", 256, 32 },
  350. { "StealthUpdate", 256, 32 },
  351. { "StealthUpgrade", 256, 32 },
  352. { "StatusBitsUpgrade", 128, 128 },
  353. { "SubObjectsUpgrade", 128, 128 },
  354. { "ExperienceScalarUpgrade", 256, 128 },
  355. { "MaxHealthUpgrade", 128, 128 },
  356. { "WeaponBonusUpgrade", 128, 64 },
  357. { "StickyBombUpdate", 64, 32 },
  358. { "FireOCLAfterWeaponCooldownUpdate", 64, 32 },
  359. { "HijackerUpdate", 64, 32 },
  360. { "ChinaMinesUpgrade", 64, 32 },
  361. { "PowerPlantUpdate", 16, 16 },
  362. { "PowerPlantUpgrade", 16, 16 },
  363. { "DefectorSpecialPower", 16, 16 },
  364. { "CheckpointUpdate", 16, 16 },
  365. { "MobNexusContain", 128, 32 },
  366. { "MobMemberSlavedUpdate", 64, 32 },
  367. { "EMPUpdate", 64, 32 },
  368. { "Overridable", 32, 32 },
  369. { "W3DGameWindow", 1024, 32 },
  370. { "SuccessState", 32, 32 },
  371. { "FailureState", 32, 32 },
  372. { "ContinueState", 32, 32 },
  373. { "SleepState", 32, 32 },
  374. { "AIDockWaitForClearanceState", 256, 32 },
  375. { "AIDockProcessDockState", 256, 32 },
  376. { "AIGuardInnerState", 32, 32 },
  377. { "AIGuardIdleState", 32, 32 },
  378. { "AIGuardOuterState", 32, 32 },
  379. { "AIGuardReturnState", 32, 32 },
  380. { "AIGuardPickUpCrateState", 32, 32 },
  381. { "AIGuardAttackAggressorState", 32, 32 },
  382. { "AITNGuardInnerState", 32, 32 },
  383. { "AITNGuardIdleState", 32, 32 },
  384. { "AITNGuardOuterState", 32, 32 },
  385. { "AITNGuardReturnState", 32, 32 },
  386. { "AITNGuardPickUpCrateState", 32, 32 },
  387. { "AITNGuardAttackAggressorState", 32, 32 },
  388. { "AIIdleState", 2400, 32 },
  389. { "AIRappelState", 600, 32 },
  390. { "AIBusyState", 600, 32 },
  391. { "AIWaitState", 600, 32 },
  392. { "AIAttackState", 4096, 32 },
  393. { "AIAttackSquadState", 600, 32 },
  394. { "AIDeadState", 600, 32 },
  395. { "AIDockState", 600, 32 },
  396. { "AIExitState", 600, 32 },
  397. { "AIGuardState", 600, 32 },
  398. { "AITunnelNetworkGuardState", 600, 32 },
  399. { "AIHuntState", 600, 32 },
  400. { "AIAttackAreaState", 600, 32 },
  401. { "AIFaceState", 1200, 32 },
  402. { "ApproachState", 600, 32 },
  403. { "DeliveringState", 600, 32 },
  404. { "ConsiderNewApproachState", 600, 32 },
  405. { "RecoverFromOffMapState", 600, 32 },
  406. { "HeadOffMapState", 600, 32 },
  407. { "CleanUpState", 600, 32 },
  408. { "HackInternetState", 600, 32 },
  409. { "PackingState", 600, 32 },
  410. { "UnpackingState", 600, 32 },
  411. { "SupplyTruckWantsToPickUpOrDeliverBoxesState", 600, 32 },
  412. { "RegroupingState", 600, 32 },
  413. { "DockingState", 600, 32 },
  414. { "ChinookEvacuateState", 32, 32 },
  415. { "ChinookHeadOffMapState", 32, 32 },
  416. { "ChinookTakeoffOrLandingState", 32, 32 },
  417. { "ChinookCombatDropState", 32, 32 },
  418. { "DozerActionPickActionPosState", 256, 32 },
  419. { "DozerActionMoveToActionPosState", 256, 32 },
  420. { "DozerActionDoActionState", 256, 32 },
  421. { "DozerPrimaryIdleState", 256, 32 },
  422. { "DozerActionState", 256, 32 },
  423. { "DozerPrimaryGoingHomeState", 256, 32 },
  424. { "JetAwaitingRunwayState", 64, 32 },
  425. { "JetOrHeliCirclingDeadAirfieldState", 64, 32 },
  426. { "HeliTakeoffOrLandingState", 64, 32 },
  427. { "JetOrHeliParkOrientState", 64, 32 },
  428. { "JetOrHeliReloadAmmoState", 64, 32 },
  429. { "SupplyTruckBusyState", 600, 32 },
  430. { "SupplyTruckIdleState", 600, 32 },
  431. { "ActAsDozerState", 600, 32 },
  432. { "ActAsSupplyTruckState", 600, 32 },
  433. { "AIDockApproachState", 256, 32 },
  434. { "AIDockAdvancePositionState", 256, 32 },
  435. { "AIDockMoveToEntryState", 256, 32 },
  436. { "AIDockMoveToDockState", 256, 32 },
  437. { "AIDockMoveToExitState", 256, 32 },
  438. { "AIDockMoveToRallyState", 256, 32 },
  439. { "AIMoveToState", 600, 32 },
  440. { "AIMoveOutOfTheWayState", 600, 32 },
  441. { "AIMoveAndTightenState", 600, 32 },
  442. { "AIMoveAwayFromRepulsorsState", 600, 32 },
  443. { "AIAttackApproachTargetState", 96, 32 },
  444. { "AIAttackPursueTargetState", 96, 32 },
  445. { "AIAttackAimAtTargetState", 96, 32 },
  446. { "AIAttackFireWeaponState", 256, 32 },
  447. { "AIPickUpCrateState", 4096, 32 },
  448. { "AIFollowWaypointPathState", 1200, 32 },
  449. { "AIFollowWaypointPathExactState", 1200, 32 },
  450. { "AIWanderInPlaceState", 600, 32 },
  451. { "AIFollowPathState", 1200, 32 },
  452. { "AIMoveAndEvacuateState", 1200, 32 },
  453. { "AIMoveAndDeleteState", 600, 32 },
  454. { "AIEnterState", 600, 32 },
  455. { "JetOrHeliReturningToDeadAirfieldState", 64, 32 },
  456. { "JetOrHeliReturnForLandingState", 64, 32 },
  457. { "TurretAIIdleState", 600, 32 },
  458. { "TurretAIIdleScanState", 600, 32 },
  459. { "TurretAIAimTurretState", 600, 32 },
  460. { "TurretAIRecenterTurretState", 600, 32 },
  461. { "TurretAIHoldTurretState", 600, 32 },
  462. { "JetOrHeliTaxiState", 64, 32 },
  463. { "JetTakeoffOrLandingState", 64, 32 },
  464. { "JetPauseBeforeTakeoffState", 64, 32 },
  465. { "AIAttackMoveToState", 600, 32 },
  466. { "AIAttackFollowWaypointPathState", 1200, 32 },
  467. { "AIWanderState", 600, 32 },
  468. { "AIPanicState", 600, 32 },
  469. { "ChinookMoveToBldgState", 32, 32 },
  470. { "ScienceInfo", 64, 32 },
  471. { "RankInfo", 32, 32 },
  472. { "FireWeaponNugget", 32, 32 },
  473. { "AttackNugget", 32, 32 },
  474. { "DeliverPayloadNugget", 32, 32 },
  475. { "ApplyRandomForceNugget", 32, 32 },
  476. { "GenericObjectCreationNugget", 512, 32 },
  477. { "SoundFXNugget", 256, 32 },
  478. { "TracerFXNugget", 32, 32 },
  479. { "RayEffectFXNugget", 32, 32 },
  480. { "LightPulseFXNugget", 64, 32 },
  481. { "ViewShakeFXNugget", 128, 32 },
  482. { "TerrainScorchFXNugget", 32, 32 },
  483. { "ParticleSystemFXNugget", 600, 32 },
  484. { "FXListAtBonePosFXNugget", 32, 32 },
  485. { "Squad", 256, 32 },
  486. { "BuildListInfo", 256, 32 },
  487. { "ScriptGroup", 128, 32 },
  488. { "OrCondition", 1024, 256 },
  489. { "ScriptAction", 2048, 512 },
  490. { "Script", 1024, 256 },
  491. { "Parameter", 8192, 1024 },
  492. { "Condition", 2048, 256 },
  493. { "Template", 32, 32 },
  494. { "ScriptList", 32, 32 },
  495. { "AttackPriorityInfo", 32, 32 },
  496. { "SequentialScript", 32, 32 },
  497. { "Win32LocalFile", 1024, 256 },
  498. { "RAMFile", 32, 32 },
  499. { "BattlePlanBonuses", 32, 32 },
  500. { "KindOfPercentProductionChange", 32, 32 },
  501. { "UserParser", 4096, 256 },
  502. { "XferBlockData", 32, 32 },
  503. { "EvaCheckInfo", 32, 32 },
  504. { "SuperweaponInfo", 32, 32 },
  505. { "NamedTimerInfo", 32, 32 },
  506. { "PopupMessageData", 32, 32 },
  507. { "FloatingTextData", 32, 32 },
  508. { "MapObject", 4096, 32 },
  509. { "Waypoint", 1024, 32 },
  510. { "PolygonTrigger", 128, 32 },
  511. { "Bridge", 32, 32 },
  512. { "Mapping", 128, 32 },
  513. { "OutputChunk", 32, 32 },
  514. { "InputChunk", 32, 32 },
  515. { "AnimateWindow", 32, 32 },
  516. { "GameFont", 32, 32 },
  517. { "NetCommandRef", 256, 32 },
  518. { "GameMessageArgument", 128, 32 },
  519. { "GameMessageParserArgumentType", 32, 32 },
  520. { "GameMessageParser", 32, 32 },
  521. { "WeaponBonusSet", 32, 32 },
  522. { "Campaign", 32, 32 },
  523. { "Mission", 32, 32 },
  524. { "ModalWindow", 32, 32 },
  525. { "NetPacket", 32, 32 },
  526. { "AISideInfo", 32, 32 },
  527. { "AISideBuildList", 32, 32 },
  528. { "MetaMapRec", 256, 32 },
  529. { "TransportStatus", 32, 32 },
  530. { "Anim2DTemplate", 32, 32 },
  531. { "ObjectTypes", 32, 32 },
  532. { "NetCommandList", 512, 32 },
  533. { "TurretAIData", 256, 32 },
  534. { "NetCommandMsg", 32, 32 },
  535. { "NetGameCommandMsg", 64, 32 },
  536. { "NetAckBothCommandMsg", 32, 32 },
  537. { "NetAckStage1CommandMsg", 32, 32 },
  538. { "NetAckStage2CommandMsg", 32, 32 },
  539. { "NetFrameCommandMsg", 32, 32 },
  540. { "NetPlayerLeaveCommandMsg", 32, 32 },
  541. { "NetRunAheadMetricsCommandMsg", 32, 32 },
  542. { "NetRunAheadCommandMsg", 32, 32 },
  543. { "NetDestroyPlayerCommandMsg", 32, 32 },
  544. { "NetDisconnectFrameCommandMsg", 32, 32 },
  545. { "NetDisconnectScreenOffCommandMsg", 32, 32 },
  546. { "NetFrameResendRequestCommandMsg", 32, 32 },
  547. { "NetKeepAliveCommandMsg", 32, 32 },
  548. { "NetDisconnectKeepAliveCommandMsg", 32, 32 },
  549. { "NetDisconnectPlayerCommandMsg", 32, 32 },
  550. { "NetPacketRouterQueryCommandMsg", 32, 32 },
  551. { "NetPacketRouterAckCommandMsg", 32, 32 },
  552. { "NetDisconnectChatCommandMsg", 32, 32 },
  553. { "NetChatCommandMsg", 32, 32 },
  554. { "NetDisconnectVoteCommandMsg", 32, 32 },
  555. { "NetProgressCommandMsg", 32, 32 },
  556. { "NetWrapperCommandMsg", 32, 32 },
  557. { "NetFileCommandMsg", 32, 32 },
  558. { "NetFileAnnounceCommandMsg", 32, 32 },
  559. { "NetFileProgressCommandMsg", 32, 32 },
  560. { "NetCommandWrapperListNode", 32, 32 },
  561. { "NetCommandWrapperList", 32, 32 },
  562. { "Connection", 32, 32 },
  563. { "User", 32, 32 },
  564. { "FrameDataManager", 32, 32 },
  565. { "DrawableIconInfo", 32, 32 },
  566. { "TintEnvelope", 128, 32 },
  567. { "DynamicAudioEventRTS", 1024, 256 },
  568. { "DrawableLocoInfo", 128, 32 },
  569. { "W3DPrototypeClass", 2048, 32 },
  570. { "EnumeratedIP", 32, 32 },
  571. { "WaterTransparencySetting", 4, 4 },
  572. // W3D pools!
  573. { "BoxPrototypeClass", 512, 32 },
  574. { "SpherePrototypeClass", 32, 32 },
  575. { "SoundRenderObjPrototypeClass", 32, 32 },
  576. { "RingPrototypeClass", 32, 32 },
  577. { "PrimitivePrototypeClass", 8192, 32 },
  578. { "HModelPrototypeClass", 256, 32 },
  579. { "ParticleEmitterPrototypeClass", 32, 32 },
  580. { "NullPrototypeClass", 32, 32 },
  581. { "HLodPrototypeClass", 512, 32 },
  582. { "DistLODPrototypeClass", 32, 32 },
  583. { "DazzlePrototypeClass", 32, 32 },
  584. { "CollectionPrototypeClass", 32, 32 },
  585. { "BoxPrototypeClass", 256, 32 },
  586. { "AggregatePrototypeClass", 32, 32 },
  587. { "OBBoxRenderObjClass", 16384, 32 },
  588. { "AABoxRenderObjClass", 32, 32 },
  589. { "VertexMaterialClass", 16384, 32 },
  590. { "TextureClass", 1024, 32 },
  591. { "CloudMapTerrainTextureClass", 32, 32 },
  592. { "ScorchTextureClass", 32, 32 },
  593. { "LightMapTerrainTextureClass", 32, 32 },
  594. { "AlphaEdgeTextureClass", 32, 32 },
  595. { "AlphaTerrainTextureClass", 32, 32 },
  596. { "TerrainTextureClass", 32, 32 },
  597. { "MeshClass", 16384, 1024 },
  598. { "HTreeClass", 8192, 32 },
  599. { "HLodDefClass", 512, 32 },
  600. { "HLodClass", 4096, 32 },
  601. { "MeshModelClass", 8192, 32 },
  602. { "ShareBufferClass", 32768, 1024 },
  603. { "AABTreeClass", 32, 32 },
  604. { "MotionChannelClass", 16384, 32 },
  605. { "BitChannelClass", 64, 32 },
  606. { "TimeCodedMotionChannelClass", 32, 32 },
  607. { "AdaptiveDeltaMotionChannelClass", 32, 32 },
  608. { "TimeCodedBitChannelClass", 32, 32 },
  609. { "UVBufferClass", 8192, 32 },
  610. { "TexBufferClass", 512, 32 },
  611. { "MatBufferClass", 512, 32 },
  612. { "MatrixMapperClass", 32, 32 },
  613. { "ScaleTextureMapperClass", 32, 32 },
  614. { "LinearOffsetTextureMapperClass", 32, 32 },
  615. { "GridTextureMapperClass", 32, 32 },
  616. { "RotateTextureMapperClass", 32, 32 },
  617. { "SineLinearOffsetTextureMapperClass", 32, 32 },
  618. { "StepLinearOffsetTextureMapperClass", 32, 32 },
  619. { "ZigZagLinearOffsetTextureMapperClass", 32, 32 },
  620. { "ClassicEnvironmentMapperClass", 32, 32 },
  621. { "EnvironmentMapperClass", 256, 32 },
  622. { "EdgeMapperClass", 32, 32 },
  623. { "WSClassicEnvironmentMapperClass", 32, 32 },
  624. { "WSEnvironmentMapperClass", 32, 32 },
  625. { "GridClassicEnvironmentMapperClass", 32, 32 },
  626. { "GridEnvironmentMapperClass", 32, 32 },
  627. { "ScreenMapperClass", 32, 32 },
  628. { "RandomTextureMapperClass", 32, 32 },
  629. { "BumpEnvTextureMapperClass", 32, 32 },
  630. { "MeshLoadContextClass", 32, 32 },
  631. { "MaterialInfoClass", 8192, 32 },
  632. { "MeshMatDescClass", 8192, 32 },
  633. { "TextureLoadTaskClass", 256, 32 },
  634. { "SortingNodeStruct", 256, 32 },
  635. { "ProxyArrayClass", 32, 32 },
  636. { "Line3DClass", 128, 32 },
  637. { "Render2DClass", 64, 32 },
  638. { "SurfaceClass", 128, 32 },
  639. { "FontCharsClassCharDataStruct", 1024, 32 },
  640. { "FontCharsBuffer", 16, 4 },
  641. { "FVFInfoClass", 128, 32 },
  642. { "TerrainTracksRenderObjClass", 128, 32 },
  643. { "DynamicIBAccessClass", 32, 32 },
  644. { "DX8IndexBufferClass", 128, 32 },
  645. { "SortingIndexBufferClass", 32, 32 },
  646. { "DX8VertexBufferClass", 128, 32 },
  647. { "SortingVertexBufferClass", 32, 32 },
  648. { "DynD3DMATERIAL8", 8192, 32 },
  649. { "DynamicMatrix3D", 512, 32 },
  650. { "MeshGeometryClass", 32, 32 },
  651. { "DynamicMeshModel", 32, 32 },
  652. { "GapFillerClass", 32, 32 },
  653. { "FontCharsClass", 64, 32 },
  654. { 0, 0, 0 }
  655. };
  656. //-----------------------------------------------------------------------------
  657. void userMemoryAdjustPoolSize(const char *poolName, Int& initialAllocationCount, Int& overflowAllocationCount)
  658. {
  659. if (initialAllocationCount > 0)
  660. return;
  661. for (const PoolSizeRec* p = sizes; p->name != NULL; ++p)
  662. {
  663. if (strcmp(p->name, poolName) == 0)
  664. {
  665. initialAllocationCount = p->initial;
  666. overflowAllocationCount = p->overflow;
  667. return;
  668. }
  669. }
  670. DEBUG_CRASH(("Initial size for pool %s not found -- you should add it to MemoryInit.cpp\n",poolName));
  671. }
  672. //-----------------------------------------------------------------------------
  673. static Int roundUpMemBound(Int i)
  674. {
  675. const int MEM_BOUND_ALIGNMENT = 4;
  676. if (i < MEM_BOUND_ALIGNMENT)
  677. return MEM_BOUND_ALIGNMENT;
  678. else
  679. return (i + (MEM_BOUND_ALIGNMENT-1)) & ~(MEM_BOUND_ALIGNMENT-1);
  680. }
  681. //-----------------------------------------------------------------------------
  682. void userMemoryManagerInitPools()
  683. {
  684. // note that we MUST use stdio stuff here, and not the normal game file system
  685. // (with bigfile support, etc), because that relies on memory pools, which
  686. // aren't yet initialized properly! so rely ONLY on straight stdio stuff here.
  687. // (not even AsciiString. thanks.)
  688. // since we're called prior to main, the cur dir might not be what
  689. // we expect. so do it the hard way.
  690. char buf[_MAX_PATH];
  691. ::GetModuleFileName(NULL, buf, sizeof(buf));
  692. char* pEnd = buf + strlen(buf);
  693. while (pEnd != buf)
  694. {
  695. if (*pEnd == '\\')
  696. {
  697. *pEnd = 0;
  698. break;
  699. }
  700. --pEnd;
  701. }
  702. strcat(buf, "\\Data\\INI\\MemoryPools.ini");
  703. FILE* fp = fopen(buf, "r");
  704. if (fp)
  705. {
  706. char poolName[256];
  707. int initial, overflow;
  708. while (fgets(buf, _MAX_PATH, fp))
  709. {
  710. if (buf[0] == ';')
  711. continue;
  712. if (sscanf(buf, "%s %d %d", poolName, &initial, &overflow ) == 3)
  713. {
  714. for (PoolSizeRec* p = sizes; p->name != NULL; ++p)
  715. {
  716. if (stricmp(p->name, poolName) == 0)
  717. {
  718. // currently, these must be multiples of 4. so round up.
  719. p->initial = roundUpMemBound(initial);
  720. p->overflow = roundUpMemBound(overflow);
  721. break; // from for-p
  722. }
  723. }
  724. }
  725. }
  726. fclose(fp);
  727. }
  728. }