]> cvs.zerfleddert.de Git - micropolis/commitdiff
Add legacy mode inspired by the work of virtuallyfun/tenox7 legacy
authorMichael Gernoth <michael@gernoth.net>
Sun, 29 Jun 2025 17:34:01 +0000 (19:34 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sun, 29 Jun 2025 17:34:01 +0000 (19:34 +0200)
Autodetect simcity.tcl in res/ and switch to legacy mode if
it is found. Working with Simcity 2.17 ressources from for
example Solaris.
Sound is not yet working.

src/sim/headers/sim.h
src/sim/sim.c
src/sim/w_tk.c
src/sim/w_update.c
src/tk/tk.h
src/tk/tkcmds.c
src/tk/tkwindow.c

index f0919778b2f0a935be68629d24a754a68902f18e..9277b42c3f3ed20398fd605ebf81f09167e2a2e0 100644 (file)
@@ -617,6 +617,7 @@ extern Sim *sim;
 extern int WireMode;
 extern int MultiPlayerMode;
 extern int SugarMode;
+extern int LegacyMode;
 extern int sim_delay;
 extern int sim_skips;
 extern int sim_skip;
index 21e4b41f0bc74cb6eabb27ea199dc84841e8426e..60fef681f2ed155ff1ee1a73fe21366bd9d2732f 100644 (file)
@@ -94,6 +94,7 @@ char *StartupName = NULL;
 int WireMode = 0;
 int MultiPlayerMode = 0;
 int SugarMode = 0;
+int LegacyMode = 0;
 int TilesAnimated = 0;
 int DoAnimation = 1;
 int DoMessages = 1;
index 991a2018a06c4f586de81e63702a78fd531e6923..686c7e80d620f68e35bc2ba336330140acacbded 100644 (file)
@@ -793,7 +793,19 @@ void tk_main(void)
 
   sim = MakeNewSim();
 
-  sprintf(initCmd, "source %s/micropolis.tcl", ResourceDir);
+  sprintf(initCmd, "%s/simcity.tcl", ResourceDir);
+  if (access(initCmd, R_OK) == 0) {
+    printf("Found %s, entering legacy mode.\n", initCmd);
+    LegacyMode = 1;
+    SugarMode = 0;
+    Eval("winfo-setlegacy");
+  }
+
+  if (!LegacyMode) {
+    sprintf(initCmd, "source %s/micropolis.tcl", ResourceDir);
+  } else {
+    sprintf(initCmd, "source %s/simcity.tcl", ResourceDir);
+  }
   filename2UNIX(initCmd);
   if (Eval(initCmd)) {
     sim_exit(1); // Just sets tkMustExit and ExitReturn
@@ -810,8 +822,13 @@ void tk_main(void)
 
   { char buf[1024];
 
-    sprintf(buf, "UIStartMicropolis {%s} {%s} {%s}",
-           HomeDir, ResourceDir, HostName);
+    if (!LegacyMode) {
+      sprintf(buf, "UIStartMicropolis {%s} {%s} {%s}",
+             HomeDir, ResourceDir, HostName);
+    } else {
+      sprintf(buf, "UIStartSimCity {%s} {%s} {} {%s}",
+             HomeDir, ResourceDir, HostName);
+    }
     filename2UNIX(buf);
     if (Eval(buf) != TCL_OK) {
       sim_exit(1); // Just sets tkMustExit and ExitReturn
index 248a31110313767e8f20e1208e594b7f5bdf5590..63c8ce0e6b7e2a28abd9a7686e2a50876605c218 100644 (file)
@@ -195,9 +195,15 @@ updateDate(void)
 
     sprintf(str, "%s %d", dateStr[m], y);
 
-    sprintf(buf,
-           "UISetDate {%s} %d %d",
-           str, m, y);
+    if (!LegacyMode) {
+      sprintf(buf,
+             "UISetDate {%s} %d %d",
+             str, m, y);
+    } else {
+      sprintf(buf,
+             "UISetDate {%s}",
+             str);
+    }
     Eval(buf);
   }
 }
@@ -278,11 +284,18 @@ void
 UpdateOptionsMenu(int options)
 {
   char buf[256];
-  sprintf(buf, "UISetOptions %d %d %d %d %d %d %d %d",
-         (options&1)?1:0, (options&2)?1:0,
-         (options&4)?1:0, (options&8)?1:0,
-         (options&16)?1:0, (options&32)?1:0,
-         (options&64)?1:0, (options&128)?1:0);
+  if (!LegacyMode) {
+    sprintf(buf, "UISetOptions %d %d %d %d %d %d %d %d",
+           (options&1)?1:0, (options&2)?1:0,
+           (options&4)?1:0, (options&8)?1:0,
+           (options&16)?1:0, (options&32)?1:0,
+           (options&64)?1:0, (options&128)?1:0);
+  } else {
+    sprintf(buf, "UISetOptions %d %d %d %d %d %d",
+           (options&1)?1:0, (options&2)?1:0,
+           (options&4)?1:0, (options&8)?1:0,
+           (options&16)?1:0, (options&32)?1:0);
+  }
   Eval(buf);
 }
 
index b70afb83312e5c5c3bc855fa91aac986d2d0aa73..a102a6d02a83ea0548e018acd326e71079006e67 100644 (file)
@@ -729,6 +729,8 @@ extern int          Tk_UpdateCmd _ANSI_ARGS_((ClientData clientData,
                            Tcl_Interp *interp, int argc, char **argv));
 extern int             Tk_WinfoCmd _ANSI_ARGS_((ClientData clientData,
                            Tcl_Interp *interp, int argc, char **argv));
+extern int             Tk_WinfoCmdSetLegacy _ANSI_ARGS_((ClientData clientData,
+                           Tcl_Interp *interp, int argc, char **argv));
 extern int             Tk_WmCmd _ANSI_ARGS_((ClientData clientData,
                            Tcl_Interp *interp, int argc, char **argv));
 extern int             Tcp_AcceptCmd _ANSI_ARGS_((ClientData clientData,
index 14207ad94618463ba7070d04bdb379f811a51a84..de8394939f9a913fc1511f3f3e977230d3cefaa2 100644 (file)
@@ -500,6 +500,22 @@ WaitWindowProc (
     }
 }
 \f
+static int LegacyMode = 0;
+
+int
+Tk_WinfoCmdSetLegacy (
+    ClientData clientData,     /* Main window associated with
+                                * interpreter. */
+    Tcl_Interp *interp,                /* Current interpreter. */
+    int argc,                  /* Number of arguments. */
+    char **argv                /* Argument strings. */
+)
+{
+    LegacyMode = 1;
+
+    return TCL_OK;
+}
+
 /*
  *----------------------------------------------------------------------
  *
@@ -750,7 +766,7 @@ Tk_WinfoCmd (
            case PseudoColor:   interp->result = "pseudocolor"; break;
            case GrayScale:     interp->result = "grayscale"; break;
            case DirectColor:   interp->result = "directcolor"; break;
-           case TrueColor:     interp->result = "truecolor"; break;
+           case TrueColor:     interp->result = LegacyMode?"pseudocolor":"truecolor"; break;
            case StaticColor:   interp->result = "staticcolor"; break;
            case StaticGray:    interp->result = "staticgray"; break;
            default:            interp->result = "unknown"; break;
index c7a7ed24fd77d15b77825c1b484927a1cbb031ae..5f568e2aeac99867921484544c9b528612de6a02 100644 (file)
@@ -134,6 +134,7 @@ TkCmd commands[] = {
     {"tkwait",         Tk_TkwaitCmd},
     {"update",         Tk_UpdateCmd},
     {"winfo",          Tk_WinfoCmd},
+    {"winfo-setlegacy",        Tk_WinfoCmdSetLegacy},
     {"wm",             Tk_WmCmd},
     {"accept",         Tcp_AcceptCmd},
     {"shutdown",       Tcp_ShutdownCmd},
Impressum, Datenschutz