Advertisement
Guest User

Untitled

a guest
Jul 21st, 2013
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.62 KB | None | 0 0
  1. #include <timer>
  2. #include <timer-logging>
  3.  
  4. enum Modes
  5. {
  6.     bool:ModeEnable,
  7.     bool:ModeIsDefault,
  8.     bool:ModeHUDEnable,
  9.     MCategory:ModeCategory,
  10.     String:ModeName[32],
  11.     ModeOrder,
  12.     Float:ModeStamina,
  13.     bool:ModeAuto,
  14.     Float:ModeBoost,
  15.     Float:ModeGravity,
  16.     bool:ModePreventMoveleft,
  17.     bool:ModePreventMoveright,
  18.     bool:ModePreventMoveforward,
  19.     bool:ModePreventMoveback,
  20.     bool:ModePreventLeft,
  21.     bool:ModePreventRight,
  22.     ModeBlockMovementDirection,
  23.     Float:ModeBlockPreSpeeding,
  24.     ModeMultiBhop,
  25.     bool:ModeSvCheats,
  26.     bool:ModeLJStats,
  27.     bool:ModeDrugs,
  28.     String:ModeTagName[32],
  29.     String:ModeTagShortName[32],
  30.     String:ModeQuickCommand[32],
  31.     Float:ModeTimeScale,
  32.     ModeFOV,
  33.     bool:ModeCustom,
  34.     String:ModeDesc[128],
  35.     bool:ModeFPSMax
  36. }
  37.  
  38. new g_Physics[MAX_MODES][Modes];
  39.  
  40. new g_ModeCount = 0;
  41. new g_ModeCountEnabled = 0;
  42. new g_ModeCountRanked = 0;
  43. new g_ModeCountRankedEnabled = 0;
  44. new g_ModeDefault = -1;
  45.  
  46. LoadPhysics()
  47. {
  48.     new String:sPath[PLATFORM_MAX_PATH];
  49.     BuildPath(Path_SM, sPath, sizeof(sPath), "configs/timer/physics.cfg");
  50.  
  51.     new Handle:hKv = CreateKeyValues("Physics");
  52.     if (!FileToKeyValues(hKv, sPath))
  53.     {
  54.         CloseHandle(hKv);
  55.         return;
  56.     }
  57.    
  58.     g_ModeCount = 0;
  59.     g_ModeCountEnabled = 0;
  60.     g_ModeCountRanked = 0;
  61.     g_ModeCountRankedEnabled = 0;
  62.     g_ModeDefault = -1;
  63.    
  64.     new modeID = -1;
  65.  
  66.     if (!KvGotoFirstSubKey(hKv))
  67.     {
  68.         CloseHandle(hKv);
  69.         return;
  70.     }
  71.    
  72.     do
  73.     {
  74.         decl String:sSectionName[32];
  75.         KvGetSectionName(hKv, sSectionName, sizeof(sSectionName));
  76.  
  77.         modeID = StringToInt(sSectionName);
  78.        
  79.         if(MAX_MODES-1 > modeID >= 0)
  80.         {
  81.             KvGetString(hKv, "name", g_Physics[g_ModeCount][ModeName], 32);
  82.            
  83.            
  84.             g_Physics[g_ModeCount][ModeEnable] = bool:KvGetNum(hKv, "enable", 0);
  85.             g_Physics[g_ModeCount][ModeOrder] = KvGetNum(hKv, "order", 0);
  86.            
  87.             g_Physics[g_ModeCount][ModeHUDEnable] = bool:KvGetNum(hKv, "hud_enable", 0);
  88.             g_Physics[g_ModeCount][ModeIsDefault] = bool:KvGetNum(hKv, "default", 0);
  89.             g_Physics[g_ModeCount][ModeCategory] = MCategory:KvGetNum(hKv, "category", 0);
  90.            
  91.             g_Physics[g_ModeCount][ModeStamina] = KvGetFloat(hKv, "stamina", -1.0);
  92.             g_Physics[g_ModeCount][ModeTimeScale] = KvGetFloat(hKv, "timescale", 1.0);
  93.            
  94.             g_Physics[g_ModeCount][ModeBoost] = KvGetFloat(hKv, "boost", 0.0);
  95.             g_Physics[g_ModeCount][ModeGravity] = KvGetFloat(hKv, "gravity", 1.0);
  96.             g_Physics[g_ModeCount][ModeAuto] = bool:KvGetNum(hKv, "auto", 0);
  97.             g_Physics[g_ModeCount][ModeLJStats] = bool:KvGetNum(hKv, "ljstats", 0);
  98.             g_Physics[g_ModeCount][ModeMultiBhop] = KvGetNum(hKv, "multimode", 0);
  99.             g_Physics[g_ModeCount][ModeFOV] = KvGetNum(hKv, "fov", 90);
  100.             g_Physics[g_ModeCount][ModeBlockMovementDirection] = KvGetNum(hKv, "block_direction", 0);
  101.             g_Physics[g_ModeCount][ModePreventMoveleft] = bool:KvGetNum(hKv, "prevent_moveleft", 0);
  102.             g_Physics[g_ModeCount][ModePreventMoveright] = bool:KvGetNum(hKv, "prevent_moveright", 0);
  103.             g_Physics[g_ModeCount][ModePreventLeft] = bool:KvGetNum(hKv, "prevent_left", 0);
  104.             g_Physics[g_ModeCount][ModePreventRight] = bool:KvGetNum(hKv, "prevent_right", 0);
  105.             g_Physics[g_ModeCount][ModePreventMoveback] = bool:KvGetNum(hKv, "prevent_back", 0);
  106.             g_Physics[g_ModeCount][ModePreventMoveforward] = bool:KvGetNum(hKv, "prevent_forward", 0);
  107.             g_Physics[g_ModeCount][ModeSvCheats] = bool:KvGetNum(hKv, "sv_cheats", 0);
  108.             g_Physics[g_ModeCount][ModeDrugs] = bool:KvGetNum(hKv, "drugs", 0);
  109.             g_Physics[g_ModeCount][ModeCustom] = bool:KvGetNum(hKv, "custom", 0);
  110.             g_Physics[g_ModeCount][ModeFPSMax] = bool:KvGetNum(hKv, "fps_max", 0);
  111.             g_Physics[g_ModeCount][ModeBlockPreSpeeding] = KvGetFloat(hKv, "prespeed", 0.0);
  112.            
  113.             KvGetString(hKv, "tag_name", g_Physics[g_ModeCount][ModeTagName], 32);
  114.             KvGetString(hKv, "tag_shortname", g_Physics[g_ModeCount][ModeTagShortName], 32);
  115.             KvGetString(hKv, "chat_command", g_Physics[g_ModeCount][ModeQuickCommand], 32);
  116.            
  117.             if (g_Physics[g_ModeCount][ModeIsDefault] && g_ModeDefault != g_ModeCount)
  118.             {
  119.                 if(g_ModeDefault != -1) Timer_LogError("PhysicsCFG: More than one default mode detected!");
  120.                
  121.                 g_ModeDefault = g_ModeCount;
  122.             }
  123.            
  124.             if(g_Physics[g_ModeCount][ModeEnable]) g_ModeCountEnabled++;
  125.             if(g_Physics[g_ModeCount][ModeCategory] == MCategory_Ranked)
  126.             {
  127.                 g_ModeCountRanked++;
  128.                 if(g_Physics[g_ModeCount][ModeEnable]) g_ModeCountRankedEnabled++;
  129.             }
  130.         }
  131.         else Timer_LogError("PhysicsCFG: Invalid mode id: %d",modeID);
  132.        
  133.         g_ModeCount++;
  134.     } while (KvGotoNextKey(hKv));
  135.    
  136.     //Timer_Log(Timer_LogLevelInfo, "PhysicsCFG: Loaded config file %d/%d [Ranked %d/%d]", g_ModeCountEnabled, g_ModeCount, g_ModeCountRankedEnabled, g_ModeCountRanked);
  137.    
  138.     CloseHandle(hKv);  
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement