]> granicus.if.org Git - xconq/blobdiff - kernel/skelconq.c
commits for 7.5.0 pre-release tarball
[xconq] / kernel / skelconq.c
index d47a853a5be1b35ab7437fc33d4c19fa902e4bc7..24fc384f7a2b766a8791f29d62083883871592f6 100644 (file)
@@ -19,6 +19,14 @@ any later version.  See the file COPYING.  */
 #include "print.h"
 #include "cmdline.h"
 
+extern Side* dside;
+
+#ifdef MAC
+int use_mac_charcodes = TRUE;
+#endif
+
+extern int autotest(void);
+
 static void init_displays(void);
 static void get_input(void);
 static void interpret_command(Obj *cmd);
@@ -50,11 +58,6 @@ static int do_action(Side *side, Unit *unit, Obj *cmd, Obj *args);
 static void show_help(Side *side, HelpNode *node);
 static void describe_commands(int arg, char *key, TextBuffer *buf);
 
-#ifdef THINK_C
-/* This is to get the command line reader in Think C on the Mac. */
-#include <console.h>
-#endif /* THINK_C */
-
 /* This structure maintains state that is local to a side's display.
    At the very least, it must track when the display is open and closed. */
 
@@ -86,11 +89,8 @@ main(int argc, char *argv[])
 {
     extern long initrandstate, randstate;
     long currandstate;
+    int option_autotest = FALSE;
 
-#ifdef THINK_C
-    /* This is how Think C picks up a command line. */
-    argc = ccommand(&argv);
-#endif
     printf("Skeleton Xconq version %s\n", version_string());
     printf("(C) %s\n", copyright_string());
     init_library_path(NULL);
@@ -106,6 +106,11 @@ main(int argc, char *argv[])
     }
     printf("\n");
     currandstate = randstate;
+    if ((argc > 1) && strcmp ("--auto", argv[1]) == 0) {
+       option_autotest = TRUE;
+       ++argv;
+       --argc;
+    }
     parse_command_line(argc, argv, general_options);
     if (currandstate != randstate) {
        printf("Random state is now %ld.\n", randstate);
@@ -126,6 +131,11 @@ main(int argc, char *argv[])
     assign_players_to_sides();
     init_signal_handlers();
     time(&skelturnstart);
+
+    if (option_autotest) {
+       exit(autotest());
+    }
+
     run_game(0);
     init_displays();
     multicmd = lispnil;
@@ -148,6 +158,10 @@ main(int argc, char *argv[])
     }
 }
 
+void
+run_ui_idler ()
+{}
+
 Player *
 add_default_player(void)
 {
@@ -322,8 +336,10 @@ list_sides(Side *side, Obj *cmd, Obj *parms)
 {
     int u;
     Side *side2;
+#if 0
     Agreement *ag;
     extern int num_agreements;
+#endif
 
     printf("Sides: (%s)\n",
           (g_use_side_priority() ? "sequential" : "simultaneous"));
@@ -347,12 +363,14 @@ list_sides(Side *side, Obj *cmd, Obj *parms)
        }
        /* (should say something about mplayer goals here) */
     }
+#if 0
     if (num_agreements > 0) {
        printf("Agreements:\n");
        for_all_agreements(ag) {
            printf("%s\n", agreement_desig(ag));
        }
     }
+#endif
 }
 
 static void
@@ -440,7 +458,7 @@ do_task_cmd(Side *side, Obj *cmd, Obj *parms)
        for (i = 0; taskdefns[i].name != NULL; ++i) {
            if (strcmp(taskname, taskdefns[i].name) == 0) {
                if (thisunit != NULL && thisunit->plan != NULL) {
-                   task = create_task(i);
+                   task = create_task((TaskType) i);
                    numargs = strlen(taskdefns[i].argtypes);
                    for (j = 0; j < numargs; ++j) {
                        if (taskparms != lispnil) {
@@ -711,6 +729,22 @@ close_displays(void)
     }
 }
 
+void
+cmd_error(Side *side, char *fmt, ...)
+{
+    char tmpnbuf[BUFSIZE];
+    va_list ap;
+
+    if (!empty_string(fmt)) {
+
+       va_start(ap, fmt);
+       vsnprintf(tmpnbuf, sizeof tmpnbuf, fmt, ap);
+       va_end(ap);
+
+       low_notify(dside, tmpnbuf);
+    }
+}
+
 void
 low_notify(Side *side, char *str)
 {
@@ -722,13 +756,15 @@ update_area_display(Side *side)
 {
 }
 
+extern int suppress_update_cell_display;
+
 /* (should count # of calls to inactive and non-displayed side...) */
 
 void
 update_cell_display(Side *side, int x, int y, int flags)
 {
     ++numcellupdatesperturn;
-    if (active_display(side)) {
+    if (active_display(side) && !suppress_update_cell_display) {
        ++numusefulcellupdatesperturn;
        DGprintf("Update %s: view of %d,%d 0x%x\n",
                 side_desig(side), x, y, flags);
@@ -848,12 +884,16 @@ update_side_display(Side *side, Side *side2, int rightnow)
        printf("Update %s: side %s%s\n",
               side_desig(side), side2desc, (rightnow ? " (now)" : ""));
     }
+}
+
+void
+update_research_display(Side *side)
+{
     if (numatypes > 0
        && g_side_can_research()
-       && side == side2
-       && side->research_topic == NOADVANCE) {
+       && dside->research_topic == NOADVANCE) {
        /* Should eventually pop up a side research dialog instead. */
-       auto_pick_side_research(side);
+       auto_pick_side_research(dside);
     }
 }
 
@@ -1053,6 +1093,15 @@ low_init_error(char *str)
     fflush(stderr);
 }
 
+static void
+report_warning(void)
+{
+    /* Ideally this would get passed back to the test framework which could
+       record it as FAIL or ERROR, but for now just make sure it doesn't
+       score as PASS.  */
+    exit(EXIT_FAILURE);
+}
+
 /* A warning just gets displayed, no other action is taken. */
 
 void
@@ -1062,6 +1111,8 @@ low_init_warning(char *str)
       printf("\n");
     fprintf(stdout, "Warning: %s.\n", str);
     fflush(stdout);
+
+    report_warning();
 }
 
 /* A run error is fatal. */
@@ -1086,6 +1137,7 @@ low_run_warning(char *str)
       printf("\n");
     fprintf(stdout, "Warning: %s.\n", str);
     fflush(stdout);
+    report_warning();
 }
 
 void
@@ -1102,11 +1154,19 @@ end_printing_forms(void)
 /* Note that the fake declaration below will cause problems if imf.h
    is included. */
 
+#if (0)
 void make_generic_image_data(char *imf);
 void
 make_generic_image_data(char *imf)
-{
-}
+{}
+#else
+#include "imf.h"
+void make_generic_image_data(ImageFamily *imf);
+void
+make_generic_image_data(ImageFamily *imf)
+{}
+#endif
+
 
 #ifdef MAC
 
@@ -1114,12 +1174,6 @@ int current_cursor;
 int receivecursor;
 int sendcursor;
 
-int
-serial_port_dialog()
-{
-    return 0;
-}
-
 #endif /* MAC */
 
 void
@@ -1138,3 +1192,10 @@ send_chat(int rid, char *str)
 {
     printf("From %d: received chat \"%s\"\n", rid, str);
 }
+
+/* Dummy function needed in run_turn_start. */
+
+void
+place_legends(Side *side)
+{
+}