/* * XScrabble - X version of the popular board game, for 1 to 4 players. * * This software comes with NO warranty whatsoever. I therefore take no * responsibility for any damages, losses or problems caused through use * or misuse of this program. * * I hereby grant permission for this program to be freely copied and * distributed by any means, provided no charge is made for it. * * Matthew Chapman, csuoq@csv.warwick.ac.uk * Nov 1994. */ /* main.c - the main function */ #include "scrab.h" #include "globals.h" #include "config.h" #include "xscrabble.xpm" #include "slate_green.xpm" /* option types and default values */ char app_def_file[256]="XScrabble"; /* application_data */ struct AppData app_data; int pauseflag = 2; int dictsize = 0; int bagptr, NUMLETTERS, NUMBLANKS; int letterscore[NUMCHAR_MAX]; int freq[NUMCHAR_MAX]; char letterchar[NUMLETTERS_MAX]; char blanktiles[NUMBLANKS_MAX]; char bag[BAGSIZE_MAX]; char PROMPT[NUMPROMPTS][256]; static XtResource resources[] = { {"load","Load",XtRBoolean,sizeof(Boolean),XtOffsetOf(struct AppData,load), XtRImmediate,(XtPointer) False}, {"version","Version",XtRInt,sizeof(int),XtOffsetOf(struct AppData,version), XtRImmediate,(XtPointer) 0}, {"players","Players",XtRInt,sizeof(int),XtOffsetOf(struct AppData,players), XtRImmediate,(XtPointer) 1}, {"bell","Bell",XtRInt,sizeof(int),XtOffsetOf(struct AppData,bell), XtRImmediate,(XtPointer) 100}, {"time","Time",XtRInt,sizeof(int),XtOffsetOf(struct AppData,timelim), XtRImmediate,(XtPointer) 0}, {"t1","T1",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[0]), XtRImmediate,(XtPointer) 0}, {"t2","T2",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[1]), XtRImmediate,(XtPointer) 0}, {"t3","T3",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[2]), XtRImmediate,(XtPointer) 0}, {"t4","T4",XtRInt,sizeof(int),XtOffsetOf(struct AppData,t[3]), XtRImmediate,(XtPointer) 0}, {"d1","D1",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[0]), XtRImmediate,":0.0"}, {"d2","D2",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[1]), XtRImmediate,":0.0"}, {"d3","D3",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[2]), XtRImmediate,":0.0"}, {"d4","D4",XtRString,sizeof(String),XtOffsetOf(struct AppData,disp[3]), XtRImmediate,":0.0"}, {"n1","N1",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[0]), XtRImmediate,""}, {"n2","N2",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[1]), XtRImmediate,""}, {"n3","N3",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[2]), XtRImmediate,""}, {"n4","N4",XtRString,sizeof(String),XtOffsetOf(struct AppData,name[3]), XtRImmediate,""}, {"dictfile","Dictfile",XtRString,sizeof(String), XtOffsetOf(struct AppData,dictfile),XtRImmediate, DICT_FILE}, {"scorefile","Scorefile",XtRString,sizeof(String), XtOffsetOf(struct AppData,scorefile),XtRImmediate, SCORE_FILE}, {"rulesfile","Rulesfile",XtRString,sizeof(String), XtOffsetOf(struct AppData,rulesfile),XtRImmediate, RULES_FILE}, {"lettercolor","LetterColor",XtRString,sizeof(String), XtOffsetOf(struct AppData,lettercolor),XtRImmediate, LETTERCOL}, {"tilecolor","TileColor",XtRString,sizeof(String), XtOffsetOf(struct AppData,tilecolor),XtRImmediate, TILECOL}, {"brightcolor","BrightColor",XtRString,sizeof(String), XtOffsetOf(struct AppData,brightcolor),XtRImmediate, BRIGHTCOL}, {"barcolor","BarColor",XtRString,sizeof(String), XtOffsetOf(struct AppData,barcolor),XtRImmediate, BARCOL} }; /* resource options */ static XrmOptionDescRec options[] = { {"-load", "*load", XrmoptionNoArg, "True" }, {"-players", "*players", XrmoptionSepArg, NULL }, {"-bell", "*bell", XrmoptionSepArg, NULL }, {"-time", "*time", XrmoptionSepArg, NULL }, {"-d1", "*d1", XrmoptionSepArg, NULL }, {"-d2", "*d2", XrmoptionSepArg, NULL }, {"-d3", "*d3", XrmoptionSepArg, NULL }, {"-d4", "*d4", XrmoptionSepArg, NULL }, {"-n1", "*n1", XrmoptionSepArg, NULL }, {"-n2", "*n2", XrmoptionSepArg, NULL }, {"-n3", "*n3", XrmoptionSepArg, NULL }, {"-n4", "*n4", XrmoptionSepArg, NULL }, {"-t1", "*t1", XrmoptionSepArg, NULL }, {"-t2", "*t2", XrmoptionSepArg, NULL }, {"-t3", "*t3", XrmoptionSepArg, NULL }, {"-t4", "*t4", XrmoptionSepArg, NULL }, {"-dictfile", "*dictfile", XrmoptionSepArg, NULL }, {"-scorefile", "*scorefile", XrmoptionSepArg, NULL }, {"-rulesfile", "*rulesfile", XrmoptionSepArg, NULL }, {"-lettercolor", "*lettercolor", XrmoptionSepArg, NULL }, {"-tilecolor", "*tilecolor", XrmoptionSepArg, NULL }, {"-brightcolor", "*brightcolor", XrmoptionSepArg, NULL }, {"-barcolor", "*barcolor", XrmoptionSepArg, NULL } }; int main(int argc, char **argv) { char defaultname[MAXPLAYERS][NAMELEN]; char mess[256]; int i,j,ind; Widget topLevel,prompts; Boolean any_comp=False; String prompts_str; for(i=0;i0) any_comp=True; } loaddict(); /* loadrules(); */ if (any_comp) makeperm(perms, factorial); clearboard(cboard); clearboard(board); makebag(); shufflebag(); for (i=0; i