Advertisement
fastman92

Limit adjuster

Feb 7th, 2015
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 11.35 KB | None | 0 0
  1.     // Initializes limit adjuster.
  2.     void CLimitAdjusterForGame::InitLimitAdjuster()
  3.     {      
  4.         const char* iniFilename;
  5.  
  6.         if(bUseDevelopmentIni)
  7.             iniFilename = "fastman92limitAdjuster_GTASA_dev.ini";
  8.         else
  9.             iniFilename = "fastman92limitAdjuster_GTASA.ini";
  10.  
  11.         this -> OpenIniFile(iniFilename);
  12.  
  13.         #if TRUE
  14.         {
  15.             CPatch::AddForbiddenMemoryRegion(0x4C9970, 0x4CDDE0);
  16.             CPatch::AddForbiddenMemoryRegion(0x598000, 0x598010);
  17.             CPatch::AddForbiddenMemoryRegion(0x5C26B0, 0x5D0240);
  18.             CPatch::AddForbiddenMemoryRegion(0x748F20, 0x77F0BB);
  19.             CPatch::AddForbiddenMemoryRegion(0x7C45E0, 0x7CF600);
  20.             CPatch::AddForbiddenMemoryRegion(0x7EC760, 0x837170);
  21.             CPatch::AddForbiddenMemoryRegion(0xCB1000, 0x1560930);
  22.         }
  23.         #endif
  24.  
  25.         CCodeMover::Init(150000, true);
  26.  
  27.         ModelIDlimit::Initialize();
  28.  
  29.         {
  30.             GetPrivateProfileStringA("ID LIMITS", "Apply ID limit patch", NULL, cTmp, sizeof(cTmp), cPath);
  31.             ModelIDlimit::EnableIDlimitsPatch(strlen(cTmp) && atoi(cTmp));
  32.         }
  33.  
  34.         // Map limits
  35.         {
  36.             MapLimits::InitChanges();
  37.  
  38.             GetPrivateProfileStringA("MAP LIMITS", "Apply paths limit patch", NULL, cTmp, sizeof(cTmp), cPath);
  39.            
  40.             if (strlen(cTmp) && atoi(cTmp))
  41.                 MapLimits::EnablePathsLimitPatch(true);
  42.  
  43.             GetPrivateProfileStringA("MAP LIMITS", "Paths map size", NULL, cTmp, sizeof(cTmp), cPath);
  44.             if (strlen(cTmp))
  45.                 MapLimits::SetPathsMapSize(atoi(cTmp));
  46.         }
  47.  
  48.         /////// ID LIMITS //////           
  49.         if (ModelIDlimit::IsIDlimitsPatchEnabled())
  50.         {
  51.             GetPrivateProfileStringA("ID LIMITS", "I want to increase the IPL limit and I know it may cause bugs", NULL, cTmp, sizeof(cTmp), cPath);
  52.  
  53.             if (strlen(cTmp) && atoi(cTmp))
  54.                 ModelIDlimit::SwitchIPLcheck(false);
  55.                
  56.             // Read possibly different values
  57.             for (eFileType type = FILE_TYPE_DFF; type != FILE_TYPE_COUNT; type++)
  58.             {
  59.                 const char* sType = tFileTypeNameMgr::GetEnumNameByMember(type);
  60.  
  61.                 GetPrivateProfileStringA("ID LIMITS", sType, NULL, cTmp, sizeof(cTmp), cPath);
  62.  
  63.                 if(strlen(cTmp))
  64.                 {
  65.                     if(type == FILE_TYPE_DAT)
  66.                     {
  67.                         printf_MessageBox(
  68.                             "FILE_TYPE_DAT is no longer valid entry for ID limits.\n"
  69.                             "If you need, set the ([MAP LIMITS] Paths map size) instead."
  70.                             );
  71.                         CLimitAdjusterForGame::TerminateProcess();
  72.                     }
  73.                     else
  74.                         ModelIDlimit::SetFileIDlimit(type, atoi(cTmp));
  75.                 }
  76.             }
  77.  
  78.             ModelIDlimit::PatchFileIDlimits();
  79.         }
  80.  
  81.         // Count of killable model IDs
  82.         GetPrivateProfileStringA("ID LIMITS", "Count of killable model IDs", NULL, cTmp, sizeof(cTmp), cPath);
  83.  
  84.         if (strlen(cTmp))
  85.             ModelIDlimit::PatchCountOfKillableModelIDs(atoi(cTmp));    
  86.        
  87.  
  88.         // Car generators
  89.         {
  90.             GetPrivateProfileStringA("CAR STREAMING", "Car generators", NULL, cTmp, sizeof(cTmp), cPath);
  91.  
  92.             int numberOfCarGenerators = 500;
  93.  
  94.             bool isCarGeneratorLimitSetFromIni = strlen(cTmp) != 0;
  95.  
  96.             if (isCarGeneratorLimitSetFromIni)
  97.                 numberOfCarGenerators = atoi(cTmp);
  98.  
  99.             // extended format?
  100.             bool isExtendedFormat = CarGeneratorLimit::IsFormatExtendedNeccessary();
  101.  
  102.             if(!isExtendedFormat)
  103.             {
  104.                 GetPrivateProfileStringA("CAR STREAMING", "Use extended format for car generators", NULL, cTmp, sizeof(cTmp), cPath);
  105.  
  106.                 if (strlen(cTmp) && atoi(cTmp))
  107.                     isExtendedFormat = true;
  108.             }
  109.  
  110.             // patch the limit
  111.             if (isCarGeneratorLimitSetFromIni || isExtendedFormat)
  112.                 CarGeneratorLimit::PatchCarGeneratorsLimit(numberOfCarGenerators, isExtendedFormat);
  113.  
  114.             // counter passes
  115.             GetPrivateProfileStringA("CAR STREAMING", "Number of process counter passes for car generators", NULL, cTmp, sizeof(cTmp), cPath);
  116.  
  117.             if(strlen(cTmp))
  118.                 CarGeneratorLimit::PatchNumberOfProcessCounterPasses(atoi(cTmp));
  119.  
  120.             // Accept any ID for car generator
  121.             GetPrivateProfileStringA("CAR STREAMING", "Accept any ID for car generator", NULL, cTmp, sizeof(cTmp), cPath);
  122.             if (atoi(cTmp))
  123.                 CarGeneratorLimit::AcceptAnyIDforCarGenerator();
  124.         }      
  125.  
  126.         ///////////////////////////////////////////////////
  127.  
  128.         ////// save game loading functions //////
  129.  
  130.         // Patches a loading function, the savefile of any length may be considered as valid savefile.
  131.  
  132.         // IPL and model flags from savefile.
  133.         ModelIDlimit::PatchSaveBlockLoadingFunctions();
  134.  
  135.         // Car generators
  136.         CarGeneratorLimit::PatchCarGeneratorSaveBlockLoadingFunction();
  137.  
  138.         // Save game of unlimited length
  139.         SaveOfVariableLength::PatchLoadingFunction();
  140.  
  141.         //////                             //////
  142.  
  143.         // Map limits
  144.         #if TRUE
  145.         {
  146.             GetPrivateProfileStringA("MAP LIMITS", "Radar map size", NULL, cTmp, sizeof(cTmp), cPath);
  147.             if (strlen(cTmp))
  148.                 MapLimits::SetRadarSize(atoi(cTmp));
  149.  
  150.             GetPrivateProfileStringA("MAP LIMITS", "Water map size", NULL, cTmp, sizeof(cTmp), cPath);
  151.             if (strlen(cTmp))
  152.                 MapLimits::SetWaterMapSize(atoi(cTmp));
  153.  
  154.             GetPrivateProfileStringA("MAP LIMITS", "World map size", NULL, cTmp, sizeof(cTmp), cPath);
  155.             if (strlen(cTmp))
  156.                 MapLimits::SetWorldMapSize(atoi(cTmp));
  157.  
  158.             GetPrivateProfileStringA("MAP LIMITS", "World sector size", NULL, cTmp, sizeof(cTmp), cPath);
  159.             if (strlen(cTmp))
  160.                 MapLimits::SetWorldSectorSize(atoi(cTmp));
  161.  
  162.             GetPrivateProfileStringA("MAP LIMITS", "World LOD sector size", NULL, cTmp, sizeof(cTmp), cPath);
  163.             if (strlen(cTmp))
  164.                 MapLimits::SetLODSectorSize(atoi(cTmp));
  165.  
  166.             MapLimits::CommitChanges();
  167.         }
  168.         #endif
  169.  
  170.         // handling.cfg limits
  171.         GetPrivateProfileStringA("HANDLING.CFG LIMITS", "Apply handling.cfg patch", NULL, cTmp, sizeof(cTmp), cPath);
  172.         if (strlen(cTmp) && atoi(cTmp))
  173.         {
  174.             struct {
  175.                 const char* property;
  176.                 void (* method)(unsigned int iValue);
  177.             } handlingLimits[] =
  178.             {
  179.                 { "Number of standard lines", HandlingCfgLimits::SetStandardLinesLimit },
  180.                 { "Number of bike lines", HandlingCfgLimits::SetBikeLinesLimit },
  181.                 { "Number of flying lines", HandlingCfgLimits::SetFlyingLinesLimit },
  182.                 { "Number of boat lines", HandlingCfgLimits::SetBoatLinesLimit },
  183.                 { "Number of animation group lines", HandlingCfgLimits::SetAnimationGroupLinesLimit }
  184.             };
  185.        
  186.             for (int i = 0; i < _countof(handlingLimits); i++)
  187.             {          
  188.                 GetPrivateProfileStringA("HANDLING.CFG LIMITS", handlingLimits[i].property, NULL, cTmp, sizeof(cTmp), cPath);
  189.  
  190.                 // printf_MessageBox("option: %s %s %d\n", handlingLimits[i].property, cTmp, atoi(cTmp));
  191.  
  192.                 if (strlen(cTmp))
  193.                     handlingLimits[i].method(atoi(cTmp));
  194.             }      
  195.        
  196.             HandlingCfgLimits::PatchHandlingCfgLimit();
  197.         }  
  198.  
  199.         // VehicleStructs
  200.         GetPrivateProfileStringA("DYNAMIC LIMITS", "VehicleStructs", NULL, cTmp, sizeof(cTmp), cPath);
  201.         if (strlen(cTmp))
  202.             DynamicLimits::SetVehicleStructs(atoi(cTmp));
  203.  
  204.         // rwObjectInstances
  205.         GetPrivateProfileStringA("DYNAMIC LIMITS", "rwObjectInstances", NULL, cTmp, sizeof(cTmp), cPath);
  206.         if (strlen(cTmp))
  207.             DynamicLimits::SetRwObjectInstances(atoi(cTmp));
  208.  
  209.         // Matrices
  210.         GetPrivateProfileStringA("DYNAMIC LIMITS", "Matrices", NULL, cTmp, sizeof(cTmp), cPath);
  211.         if (strlen(cTmp))
  212.             DynamicLimits::SetMatrices(atoi(cTmp));
  213.  
  214.         // IPL: inst
  215.         GetPrivateProfileStringA("IPL", "Buildings", NULL, cTmp, sizeof(cTmp), cPath);
  216.         if (strlen(cTmp))
  217.             IPLsectionLimits::SetIplBuildings(atoi(cTmp));
  218.  
  219.         // IPL: inst entries per file
  220.         GetPrivateProfileStringA("IPL", "Inst entries per file", NULL, cTmp, sizeof(cTmp), cPath);
  221.         if (strlen(cTmp))
  222.             IPLsectionLimits::SetInstLimitPerFile(atoi(cTmp));
  223.  
  224.         // IPL: map zones
  225.         GetPrivateProfileStringA("IPL", "Map zones", NULL, cTmp, sizeof(cTmp), cPath);
  226.         if (strlen(cTmp))
  227.             IPLsectionLimits::SetMapZones(atoi(cTmp));
  228.  
  229.         // IPL: navigation zones
  230.         GetPrivateProfileStringA("IPL", "Navigation zones", NULL, cTmp, sizeof(cTmp), cPath);
  231.         if (strlen(cTmp))
  232.             IPLsectionLimits::SetNavigationZones(atoi(cTmp));
  233.  
  234.         // IPL: occl for interiors
  235.         GetPrivateProfileStringA("IPL", "Interior occluders", NULL, cTmp, sizeof(cTmp), cPath);
  236.         if (strlen(cTmp))
  237.             IPLsectionLimits::SetInteriorOccluders(atoi(cTmp));
  238.  
  239.         // ; IPL: occl for map (1000)
  240.         GetPrivateProfileStringA("IPL", "Occluders", NULL, cTmp, sizeof(cTmp), cPath);
  241.         if (strlen(cTmp))
  242.             IPLsectionLimits::SetOccluders(atoi(cTmp));
  243.  
  244.         // ColModels
  245.         GetPrivateProfileStringA("DYNAMIC LIMITS", "ColModels", NULL, cTmp, sizeof(cTmp), cPath);
  246.         if (strlen(cTmp))
  247.             DynamicLimits::SetColModels(atoi(cTmp));
  248.  
  249.         // IDE: objs
  250.         GetPrivateProfileStringA("IDE LIMITS", "IDE Objects Type 1", NULL, cTmp, sizeof(cTmp), cPath);
  251.         if (strlen(cTmp))
  252.             IDEsectionLimits::SetIDEobjsType1(atoi(cTmp));
  253.  
  254.         // IDE: objs
  255.         GetPrivateProfileStringA("IDE LIMITS", "IDE Objects Type 2", NULL, cTmp, sizeof(cTmp), cPath);
  256.         if (strlen(cTmp))
  257.             IDEsectionLimits::SetIDEobjsType2(atoi(cTmp));
  258.  
  259.         // IDE: tobjs
  260.         GetPrivateProfileStringA("IDE LIMITS", "Hier Objects", NULL, cTmp, sizeof(cTmp), cPath);
  261.         if (strlen(cTmp))
  262.             IDEsectionLimits::SetHierObjects(atoi(cTmp));
  263.  
  264.         // IDE: tobjs
  265.         GetPrivateProfileStringA("IDE LIMITS", "Timed Objects", NULL, cTmp, sizeof(cTmp), cPath);
  266.         if (strlen(cTmp))
  267.             IDEsectionLimits::SetTimedObjects(atoi(cTmp));
  268.  
  269.         // IDE : cars
  270.         GetPrivateProfileStringA("IDE LIMITS", "Vehicle Models", NULL, cTmp, sizeof(cTmp), cPath);
  271.         if (strlen(cTmp))
  272.             IDEsectionLimits::SetVehicleModels(atoi(cTmp));
  273.  
  274.         // IDE : peds
  275.         GetPrivateProfileStringA("IDE LIMITS", "Ped Models", NULL, cTmp, sizeof(cTmp), cPath);
  276.         if (strlen(cTmp))
  277.             IDEsectionLimits::SetPedModels(atoi(cTmp));
  278.  
  279.         // IDE : peds
  280.         GetPrivateProfileStringA("IDE LIMITS", "Weapon Models", NULL, cTmp, sizeof(cTmp), cPath);
  281.         if (strlen(cTmp))
  282.             IDEsectionLimits::SetWeaponModels(atoi(cTmp));
  283.  
  284.         //// IMG limits ////
  285.         GetPrivateProfileStringA("IMG LIMITS", "Max number of IMG archives", NULL, cTmp, sizeof(cTmp), cPath);     
  286.  
  287.         if (strlen(cTmp))
  288.             IMGlimits::SetLimitOfIMGarchives(atoi(cTmp));
  289.  
  290.  
  291.         // Cargrp cars per group
  292.         GetPrivateProfileStringA("CAR STREAMING", "Cargrp cars per group", NULL, cTmp, sizeof(cTmp), cPath);
  293.         if (strlen(cTmp))
  294.             CargrpLimit::SetCargrpLimit(34, atoi(cTmp));
  295.  
  296.         // Car streaming : DesiredNumberOfVehiclesLoaded
  297.         GetPrivateProfileStringA("CAR STREAMING", "Streaming_DesiredNumberOfVehiclesLoaded", NULL, cTmp, sizeof(cTmp), cPath);
  298.         if (strlen(cTmp))
  299.             StreamingLimits::SetStreamingDesiredNumberOfVehiclesLoaded(atoi(cTmp));
  300.  
  301.         // Car streaming
  302.         GetPrivateProfileStringA("STREAMING", "Memory available", NULL, cTmp, sizeof(cTmp), cPath);
  303.         if (strlen(cTmp))
  304.             StreamingLimits::SetMemoryAvailable(atoi(cTmp) * 1024 * 1024);
  305.  
  306.         // SCM limits
  307.         {
  308.             GetPrivateProfileStringA("SCM LIMITS", "Max size of MAIN segment", NULL, cTmp, sizeof(cTmp), cPath);
  309.  
  310.             if (strlen(cTmp))
  311.                 SCMlimits::SetMaxMAINsegmentSize(atoi(cTmp));
  312.  
  313.             GetPrivateProfileStringA("SCM LIMITS", "Max mission size", NULL, cTmp, sizeof(cTmp), cPath);
  314.  
  315.             if (strlen(cTmp))
  316.                 SCMlimits::SetMaxMissionSize(atoi(cTmp));
  317.  
  318.             SCMlimits::PatchScriptLimits();
  319.         }
  320.  
  321.         // SPECIAL : MakeHelicoptersLandOnWater
  322.         GetPrivateProfileStringA("SPECIAL", "Make helicopters land on water when cars on water cheat enabled", NULL, cTmp, sizeof(cTmp), cPath);
  323.         if (atoi(cTmp))
  324.             SpecialLimits::MakeHelicoptersLandOnWater();
  325.  
  326.         // SPECIAL : Disable plane speed limit
  327.         GetPrivateProfileStringA("SPECIAL", "Disable plane speed limit", NULL, cTmp, sizeof(cTmp), cPath);
  328.         if (atoi(cTmp))
  329.             SpecialLimits::DisablePlaneSpeedLimit();
  330.  
  331.         // Patcher
  332.         GetPrivateProfileStringA("PLUGIN PATCHES", "Enable plugin patches", NULL, cTmp, sizeof(cTmp), cPath);
  333.         if (atoi(cTmp))
  334.             CThePluginPatches::RegisterPatcher();
  335.     }
  336. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement