Advertisement
v00d00m4n

eduke32 wrapper for megaton edition compatibility

Mar 26th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.27 KB | None | 0 0
  1.                 // Megaton Edition compatibility layer
  2.                 // put this into game.c inside CommandLine function right after debughelp
  3.                 // TODO:
  4.                 // 1) replace hardcoded names of files and indexes with
  5.                 // ini\cfg configurable stuff. My original AutoIt wrapper code for reference
  6.                 /*
  7.                 Global $Ini = "duke3d.ini"
  8.                 Global $Global = "Global"
  9.                 Global $Filter = "-addon"
  10.                 Global $AddonIndex = 0
  11.                 Global $Title = "Duke Nukem 3D"
  12.                 Global $Exe = "eduke32.exe"
  13.                 Global $Args
  14.                 Global $WinState = 1
  15.  
  16.                 GetIniSettings(1)
  17.                 GetCmdLine()
  18.                 GetIniSettings(2)
  19.                 RunDuke3D()
  20.                 Exit
  21.  
  22.                 Func GetCmdLine()
  23.                     If $CmdLine[0] > 0 Then
  24.                         If $CmdLine[1] = $Filter Then
  25.                             ;MsgBox(4096, $Title, $CmdLine[1])
  26.                             If $CmdLine[2] = True Then
  27.                                 Global $AddonIndex = $CmdLine[2]
  28.                             EndIf
  29.                         EndIf
  30.                     EndIf
  31.                 EndFunc   ;==>GetCmdLine
  32.  
  33.                 Func GetIniSettings($Mode)
  34.                     If FileExists($Ini) Then
  35.                         If $Mode = 1 Then
  36.                             Global $ModeSettings = IniReadSection($Ini, $Global)
  37.                             For $m = 1 To $ModeSettings[0][0]
  38.                                 If $ModeSettings[$m][0] = "Filter" Then
  39.                                     If $ModeSettings[$m][1] = True Then
  40.                                         Global $Filter = $ModeSettings[$m][1]
  41.                                     EndIf
  42.                                 EndIf
  43.                             Next
  44.                         ElseIf $Mode = 2 Then
  45.                             Global $ModeSettings = IniReadSection($Ini, $AddonIndex)
  46.                             For $m = 1 To $ModeSettings[0][0]
  47.                                 If $ModeSettings[$m][0] = "Title" Then
  48.                                     If $ModeSettings[$m][1] = True Then
  49.                                         Global $Title = $ModeSettings[$m][1]
  50.                                     EndIf
  51.                                 ElseIf $ModeSettings[$m][0] = "Exe" Then
  52.                                     If $ModeSettings[$m][1] = True Then
  53.                                         Global $Exe = $ModeSettings[$m][1]
  54.                                     EndIf
  55.                                 ElseIf $ModeSettings[$m][0] = "Args" Then
  56.                                     If $ModeSettings[$m][1] = True Then
  57.                                         Global $Args = $ModeSettings[$m][1]
  58.                                     EndIf
  59.                                 ElseIf $ModeSettings[$m][0] = "WinState" Then
  60.                                     If $ModeSettings[$m][1] = True Then
  61.                                         Global $WinState = $ModeSettings[$m][1]
  62.                                     EndIf
  63.                                 EndIf
  64.                             Next
  65.                         EndIf
  66.                     EndIf
  67.                     ;MsgBox(4096, $Title, $Exe & ' ' & $Args)
  68.                 EndFunc   ;==>GetIniSettings
  69.                
  70.                 Func RunDuke3D()
  71.                     RunWait($Exe & ' ' & $Args, @WorkingDir, $WinState)
  72.                 EndFunc   ;==>RunDuke3D
  73.                 */
  74.                 // 2) rename saves name pattern and ext for compatibility with Steam Cloud
  75.                 // to do so probably g_addonIndex should be used to differ names of saves according to addon index
  76.                 // give original duke3d 0 index, backward compatibility with old save names and ext should be added,
  77.                 // we dont want to frustrate people by making their old saves invisible, dont we?
  78.                 // also steam cloud storage size per D3DME could be limited.
  79.                 // i have idea to make dirty trick that will rename Megaton edition compatible saves to eduke32 format
  80.                 // on start, and on exit will rename them back to megaton format to let steam hook these saves.
  81.                 // from Russia with love, v00d00m4n
  82.                 // sorry for some garbage comments, im total n00b here, remove if you will annoy you
  83.                 if (!Bstrcasecmp(c+1,"addon"))
  84.                 {
  85.                     if (argc > i+1)
  86.                     {
  87.                         switch (argv[i+1])
  88.                         {
  89.                                 // better to do it with for loop for ulimited number of addons but for now 3 will do
  90.                             case "1":
  91.                                 // settings should be equal to
  92.                                 // -jAddons -gDUKEDC.GRP -xGAME.CON
  93.                                 // not sure if last con needed, added it just in case to be sure that con loaded from addon grp and not default one
  94.                                 // def added just in case for mod compatibility and separation of addon def files!
  95.                                 // Will missing def interrupt eduke loading?
  96.                                 G_AddPath("Addons")
  97.                                 G_AddGroup("DUKEDC.GRP")
  98.                                 clearScriptNamePtr();
  99.                                 g_scriptNamePtr = dup_filename("GAME.CON");
  100.                                 initprintf("Using CON file \"%s\".\n",g_scriptNamePtr);
  101.                                 clearDefNamePtr();
  102.                                 g_defNamePtr = dup_filename("dukedc.def");
  103.                                 initprintf("Using DEF file \"%s\".\n",g_defNamePtr);
  104.                                 i++;
  105.                                 break;
  106.                             case "2":
  107.                                 // settings should be equal to
  108.                                 // -jAddons -gNWINTER.GRP -xNWINTER.CON
  109.                                 // this case is different due of non standard con name
  110.                                 G_AddPath("Addons")
  111.                                 G_AddGroup("NWINTER.GRP")
  112.                                 clearScriptNamePtr();
  113.                                 g_scriptNamePtr = dup_filename("NWINTER.CON");
  114.                                 initprintf("Using CON file \"%s\".\n",g_scriptNamePtr);
  115.                                 clearDefNamePtr();
  116.                                 g_defNamePtr = dup_filename("nwinter.def");
  117.                                 initprintf("Using DEF file \"%s\".\n",g_defNamePtr);
  118.                                 i++;
  119.                                 break;
  120.                             case "3":
  121.                                 // settings should be equal to
  122.                                 // -jAddons -gVACATION.GRP -xGAME.CON
  123.                                 // same as with DC
  124.                                 G_AddPath("Addons")
  125.                                 G_AddGroup("VACATION.GRP")
  126.                                 clearScriptNamePtr();
  127.                                 g_scriptNamePtr = dup_filename("GAME.CON");
  128.                                 initprintf("Using CON file \"%s\".\n",g_scriptNamePtr);
  129.                                 clearDefNamePtr();
  130.                                 g_defNamePtr = dup_filename("vacation.def");
  131.                                 initprintf("Using DEF file \"%s\".\n",g_defNamePtr);
  132.                                 i++;
  133.                                 break;
  134.                         }
  135.                         //i++;
  136.                     }
  137.                     i++;
  138.                     continue;
  139.                 }
  140.                 // compat layer end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement