summaryrefslogtreecommitdiff
path: root/globals.c
diff options
context:
space:
mode:
Diffstat (limited to 'globals.c')
-rw-r--r--globals.c983
1 files changed, 983 insertions, 0 deletions
diff --git a/globals.c b/globals.c
new file mode 100644
index 0000000..0eb0ad7
--- /dev/null
+++ b/globals.c
@@ -0,0 +1,983 @@
+/*
+
+ viDOOM - level editor for DOOM
+
+ Copyright (C) 2000 Ian Cowburn (ianc@noddybox.demon.co.uk)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+ -------------------------------------------------------------------------
+
+ Global data
+
+ All the stuff from INI file and from the config files. Note this object
+ also drives other objects so that the list of things they maintain is
+ initialised.
+
+*/
+static const char rcs_id[]="$Id$";
+
+#include "config.h"
+#include "globals.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "ini.h"
+#include "gfx.h"
+#include "texture.h"
+#include "things.h"
+#include "linedefs.h"
+#include "sectors.h"
+
+
+/* Constants
+*/
+#define MAXLEN 1024
+
+#define M_NONE -1
+#define M_THING_TYPES 0
+#define M_SECTOR_TYPES 1
+#define M_LINEDEF_FLAGS 2
+#define M_INCLUDE 3
+#define M_THING_FLAGS 4
+#define M_LINEDEF_TYPES 5
+#define M_LINEDEF_DEFAULTS 6
+#define M_SECTOR_STYLES 7
+#define M_LINEDEF_FLAGS_EXTRA 8
+#define M_EMPTY_TEXTURE_NAME 9
+#define M_THING_CLASSES 10
+#define M_LINEDEF_CLASSES 11
+#define M_SECTOR_CLASSES 12
+#define M_NORMAL_TYPES 13
+#define M_LINEDEF_CHECK_DEFAULT 14
+
+
+/* INI sections
+*/
+#define GAME_INI "Game"
+#define EDITOR_INI "Editor"
+#define VIDOOM_INI "viDOOM"
+#define CLINEDEF_INI "Check LINEDEF"
+#define BUILD_INI "Node Builder"
+
+#define DOOM_INI "Doom"
+#define ULT_DOOM_INI "Ultimate Doom"
+#define DOOM2_INI "Doom 2"
+#define FINAL_TNT_INI "TNT:Evilution"
+#define FINAL_PLUT_INI "Plutonia Experiment"
+#define ZDOOM_INI "ZDoom"
+
+/* ------------------------------ Game type
+*/
+GameType game=DOOM_2;
+LevelStyle level_style=DOOM_2_LEVELS;
+int ask_for_game_type=FALSE;
+char *game_name="Doom 2 - Hell on Earth";
+
+
+/* ------------------------------ Paths
+*/
+char IWAD_path[PATH_MAX+1]="." DIRSEP "DOOM2.WAD";
+char PWAD_dir[PATH_MAX+1]="." DIRSEP;
+char PWAD_preload[MAX_PRELOAD_LEN]="";
+static char config_file[PATH_MAX+1]="doom2.cfg";
+
+
+/* ------------------------------ Editor configuration
+*/
+int disp_width=640;
+int disp_height=480;
+int grid_onoff=TRUE;
+int grid_lock=TRUE;
+int grid_size=64;
+double gfx_brighten=1.0;
+int vertex_rad=5;
+Hover hover_select=HOVER_NONE;
+int clear_on_move=TRUE;
+int clear_on_menu=FALSE;
+Hover insert_select=HOVER_NONE;
+SectorMoveMode sector_move=MOVE_RIGHT;
+int ask_middle_on_2sided=TRUE;
+int default_light_level=200;
+int default_floor_height=0;
+int default_ceiling_height=256;
+NewSelect new_2sided_select=NEWSELECT_ASK;
+LinedefMerge merge_linedef=MERGE_ASK;
+int auto_block_linedefs=TRUE;
+int default_scale=10;
+DefaultEdit default_edit_mode=EDIT_SECTOR;
+int linedef_select=2;
+int tag_highlight=TRUE;
+int show_full_linedef_info=FALSE;
+
+
+/* ------------------------------ viDOOM configuration
+*/
+int sort_textures=TRUE;
+int sort_flats=TRUE;
+int show_titlepic=TRUE;
+int load_textures=TRUE;
+int load_flats=TRUE;
+int load_sprites=TRUE;
+int map_warn=TRUE;
+int map_exit_warn=TRUE;
+int initial_empty_map=FALSE;
+int overwrite_warning=TRUE;
+
+/* ------------------------------ Linedef flags bit and mask
+*/
+int side2_bit=-1;
+int side2_mask;
+int block_bit=-1;
+int block_mask;
+int lower_peg_bit=-1;
+int lower_peg_mask;
+int upper_peg_bit=-1;
+int upper_peg_mask;
+
+/* ------------------------------ Normal values
+*/
+int normal_linedef=0;
+int normal_sector=0;
+
+/* ------------------------------ LINEDEF checking
+*/
+int check_line_assume_yes=FALSE;
+int check_1side_lower=TRUE;
+int check_1side_middle=TRUE;
+int check_1side_upper=TRUE;
+int check_2side_lower=TRUE;
+int check_2side_middle=TRUE;
+int check_2side_same_sector=TRUE;
+int check_2side_upper=TRUE;
+
+/* ------------------------------ Node Builder config
+*/
+int use_build=FALSE;
+char build_cmd[PATH_MAX+1]="bsp.exe";
+char build_ignore[PATH_MAX+1]="";
+char build_in[PATH_MAX+1]="%";
+char build_out[PATH_MAX+1]="%";
+int build_in_before_out=TRUE;
+int build_always_view=TRUE;
+
+
+
+/* ------------------------------ Texture names
+*/
+char empty_texture[256]="-";
+char linedef_check_default[256]="-";
+
+
+/* ------------------------------ INI tables to data
+*/
+
+#define INI_FOR_GAME(g) { \
+ INI_STR, g, "iwad", \
+ IWAD_path, NULL \
+ }, \
+ { \
+ INI_STR, g, "pwad_dir", \
+ PWAD_dir, NULL \
+ }, \
+ { \
+ INI_TOK, g, "level_style", \
+ &level_style, level_style_tok \
+ }, \
+ { \
+ INI_STR, g, "preload", \
+ PWAD_preload, NULL \
+ }, \
+ { \
+ INI_STR, g, "vidoom_config", \
+ config_file, NULL \
+ }
+
+
+static TokenTable game_type_tok[]=
+ {
+ {"Doom",DOOM},
+ {"Ultimate Doom",ULTIMATE_DOOM},
+ {"Doom 2",DOOM_2},
+ {"TNT:Evilution",FINAL_TNT},
+ {"Plutonia Experiment",FINAL_PLUTONIA},
+ {"ZDoom",ZDOOM},
+ {NULL,0}
+ };
+
+static TokenTable level_style_tok[]=
+ {
+ {"Doom",DOOM_LEVELS},
+ {"Ultimate Doom",ULTIMATE_DOOM_LEVELS},
+ {"Doom 2",DOOM_2_LEVELS},
+ {NULL,0}
+ };
+
+static TokenTable hover_type_tok[]=
+ {
+ {"none",HOVER_NONE},
+ {"add",HOVER_ADD},
+ {"single",HOVER_SINGLE},
+ {NULL,0}
+ };
+
+static TokenTable smove_type_tok[]=
+ {
+ {"all",MOVE_ALL},
+ {"left",MOVE_LEFT},
+ {"right",MOVE_RIGHT},
+ {NULL,0}
+ };
+
+static TokenTable new_select_tok[]=
+ {
+ {"never",NEWSELECT_NEVER},
+ {"ask",NEWSELECT_ASK},
+ {"select",NEWSELECT_SELECT},
+ {NULL,0}
+ };
+
+static TokenTable merge_mode_tok[]=
+ {
+ {"never",MERGE_NEVER},
+ {"ask",MERGE_ASK},
+ {"always",MERGE_ALWAYS},
+ {NULL,0}
+ };
+
+static TokenTable edit_mode_tok[]=
+ {
+ {"sector",EDIT_SECTOR},
+ {"vertex",EDIT_VERTEX},
+ {"linedef",EDIT_LINEDEF},
+ {"thing",EDIT_THING},
+ {"multi",EDIT_MULTI},
+ {NULL,0}
+ };
+
+
+static INI_Table part1_ini[]=
+ {
+ /* Game type
+ */
+ {
+ INI_TOK, GAME_INI, "game",
+ &game, game_type_tok
+ },
+ {
+ INI_TOK, GAME_INI, "ask",
+ &ask_for_game_type, ini_yesno
+ },
+ {
+ INI_INT, EDITOR_INI, "width",
+ &disp_width, NULL
+ },
+ {
+ INI_INT, EDITOR_INI, "height",
+ &disp_height, NULL
+ },
+ };
+
+static INI_Table part2_ini[]=
+ {
+ /* Editor
+ */
+ {
+ INI_TOK, EDITOR_INI, "grid",
+ &grid_onoff, ini_yesno
+ },
+ {
+ INI_TOK, EDITOR_INI, "grid_lock",
+ &grid_lock, ini_yesno
+ },
+ {
+ INI_INT, EDITOR_INI, "grid_size",
+ &grid_size, NULL
+ },
+ {
+ INI_DOUBLE, EDITOR_INI, "bright",
+ &gfx_brighten, NULL
+ },
+ {
+ INI_INT, EDITOR_INI, "vertex_radius",
+ &vertex_rad, NULL
+ },
+ {
+ INI_TOK, EDITOR_INI, "hover_select",
+ &hover_select, hover_type_tok
+ },
+ {
+ INI_TOK, EDITOR_INI, "clear_on_move",
+ &clear_on_move, ini_yesno
+ },
+ {
+ INI_TOK, EDITOR_INI, "clear_on_menu",
+ &clear_on_menu, ini_yesno
+ },
+ {
+ INI_TOK, EDITOR_INI, "insert_select",
+ &insert_select, hover_type_tok
+ },
+ {
+ INI_TOK, EDITOR_INI, "sector_move",
+ &sector_move, smove_type_tok
+ },
+ {
+ INI_TOK, EDITOR_INI, "ask_middle_on_2sided",
+ &ask_middle_on_2sided, ini_yesno
+ },
+ {
+ INI_INT, EDITOR_INI, "default_light_level",
+ &default_light_level, NULL
+ },
+ {
+ INI_INT, EDITOR_INI, "default_floor_height",
+ &default_floor_height, NULL
+ },
+ {
+ INI_INT,EDITOR_INI,"default_ceiling_height",
+ &default_ceiling_height, NULL
+ },
+ {
+ INI_TOK, EDITOR_INI, "new_2sided_select",
+ &new_2sided_select, new_select_tok
+ },
+ {
+ INI_TOK, EDITOR_INI, "merge_linedef",
+ &merge_linedef, merge_mode_tok
+ },
+ {
+ INI_TOK, EDITOR_INI, "auto_block_linedefs",
+ &auto_block_linedefs, ini_yesno
+ },
+ {
+ INI_INT, EDITOR_INI, "default_scale",
+ &default_scale, NULL
+ },
+ {
+ INI_TOK, EDITOR_INI, "default_edit_mode",
+ &default_edit_mode, edit_mode_tok
+ },
+ {
+ INI_INT, EDITOR_INI, "linedef_select",
+ &linedef_select, NULL
+ },
+ {
+ INI_TOK, EDITOR_INI,"tag_highlight",
+ &tag_highlight, ini_yesno
+ },
+ {
+ INI_TOK,EDITOR_INI,"show_full_linedef_info",
+ &show_full_linedef_info, ini_yesno
+ },
+
+ /* viDOOM
+ */
+ {
+ INI_TOK, VIDOOM_INI, "sort_texture_names",
+ &sort_textures, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "sort_flat_names",
+ &sort_flats, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "show_titlepic",
+ &show_titlepic, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "load_textures",
+ &load_textures, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "load_flats",
+ &load_flats, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "load_sprites",
+ &load_sprites, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "map_clear_warning",
+ &map_warn, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "map_exit_warning",
+ &map_exit_warn, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "initial_empty_map",
+ &initial_empty_map, ini_yesno
+ },
+ {
+ INI_TOK, VIDOOM_INI, "overwrite_warning",
+ &overwrite_warning, ini_yesno
+ },
+
+ /* Check LINEDEF
+ */
+ {
+ INI_TOK, CLINEDEF_INI, "assume_yes",
+ &check_line_assume_yes, ini_yesno
+ },
+ {
+ INI_TOK, CLINEDEF_INI, "check_1side_lower",
+ &check_1side_lower, ini_yesno
+ },
+ {
+ INI_TOK, CLINEDEF_INI, "check_1side_middle",
+ &check_1side_middle, ini_yesno
+ },
+ {
+ INI_TOK, CLINEDEF_INI, "check_1side_upper",
+ &check_1side_upper, ini_yesno
+ },
+ {
+ INI_TOK, CLINEDEF_INI, "check_2side_lower",
+ &check_2side_lower, ini_yesno
+ },
+ {
+ INI_TOK, CLINEDEF_INI, "check_2side_middle",
+ &check_2side_middle, ini_yesno
+ },
+ {
+ INI_TOK, CLINEDEF_INI,
+ "check_2side_same_sector",
+ &check_2side_same_sector, ini_yesno
+ },
+ {
+ INI_TOK, CLINEDEF_INI, "check_2side_upper",
+ &check_2side_upper, ini_yesno
+ },
+
+ /* Node builder
+ */
+ {
+ INI_TOK, BUILD_INI, "use",
+ &use_build, ini_yesno
+ },
+ {
+ INI_STR, BUILD_INI, "command",
+ build_cmd, NULL
+ },
+ {
+ INI_STR, BUILD_INI, "ignore",
+ build_ignore, NULL
+ },
+ {
+ INI_STR, BUILD_INI, "infile",
+ build_in, NULL
+ },
+ {
+ INI_STR, BUILD_INI, "outfile",
+ build_out, NULL
+ },
+ {
+ INI_TOK, BUILD_INI, "in_before_out",
+ &build_in_before_out, ini_yesno
+ },
+ {
+ INI_TOK, BUILD_INI, "always_view_output",
+ &build_always_view, ini_yesno
+ },
+ };
+
+static INI_Table doom_ini[]={INI_FOR_GAME(DOOM_INI)};
+static INI_Table ult_doom_ini[]={INI_FOR_GAME(ULT_DOOM_INI)};
+static INI_Table doom_2_ini[]={INI_FOR_GAME(DOOM2_INI)};
+static INI_Table tnt_ini[]={INI_FOR_GAME(FINAL_TNT_INI)};
+static INI_Table plut_ini[]={INI_FOR_GAME(FINAL_PLUT_INI)};
+static INI_Table zdoom_ini[]={INI_FOR_GAME(ZDOOM_INI)};
+
+
+
+/* ------------------------------ TYPES
+*/
+typedef struct
+ {
+ char *str;
+ int val;
+ } StrList;
+
+
+/* ------------------------------ PRIVATE FUNCTIONS
+*/
+
+static void CheckVals(void)
+{
+ FILE *fp;
+
+ grid_size=MAX(grid_size,2);
+ default_light_level=default_light_level%256;
+ linedef_select=MAX(linedef_select,1);
+
+ /* Check config file exists
+ */
+ if (!(fp=fopen(config_file,"r")))
+ GFX_exit(EXIT_FAILURE,"Couldn't open config file %s\n",config_file);
+
+ fclose(fp);
+}
+
+
+static int StrToInt(StrList s[],char *val,int def)
+{
+ int f;
+ int m;
+
+ f=0;
+ m=def;
+
+ while((s[f].str)&&(m==def))
+ {
+ if (STREQ(s[f].str,val))
+ m=s[f].val;
+ f++;
+ }
+
+ return(m);
+}
+
+
+static char *GetLine(FILE *fp)
+{
+ static char s[MAXLEN+1];
+ int l,f;
+
+ fgets(s,MAXLEN,fp);
+
+ if (feof(fp))
+ return(FALSE);
+
+ l=strlen(s)-1;
+
+ if ((l>=0)&&(s[l]=='\n'))
+ s[l]=0;
+
+ l=strlen(s)-1;
+
+ if ((l>=0)&&(s[l]=='\r'))
+ s[l]=0;
+
+ l=strlen(s);
+ for(f=0;f<l;f++)
+ if (!isspace(s[f]))
+ if (s[f]=='#')
+ return(GetLine(fp));
+ else
+ return(s+f);
+
+ return(GetLine(fp));
+}
+
+
+static void DoLoadConfig(char *fn)
+{
+ static StrList mode_list[]={{"%THING_TYPES",M_THING_TYPES},
+ {"%SECTOR_TYPES",M_SECTOR_TYPES},
+ {"%LINEDEF_TYPES",M_LINEDEF_TYPES},
+ {"%INCLUDE_FILES",M_INCLUDE},
+ {"%THING_FLAGS",M_THING_FLAGS},
+ {"%LINEDEF_FLAGS",M_LINEDEF_FLAGS},
+ {"%LINEDEF_DEFAULTS",M_LINEDEF_DEFAULTS},
+ {"%SECTOR_STYLES",M_SECTOR_STYLES},
+ {"%LINEDEF_FLAGS_EXTRA",M_LINEDEF_FLAGS_EXTRA},
+ {"%EMPTY_TEXTURE_NAME",M_EMPTY_TEXTURE_NAME},
+ {"%THING_CLASSES",M_THING_CLASSES},
+ {"%LINEDEF_CLASSES",M_LINEDEF_CLASSES},
+ {"%SECTOR_CLASSES",M_SECTOR_CLASSES},
+ {"%NORMAL_TYPES",M_NORMAL_TYPES},
+ {"%LINEDEF_CHECK_DEFAULT",
+ M_LINEDEF_CHECK_DEFAULT},
+ {NULL,0}};
+
+ FILE *fp;
+ char *line;
+ char orig[MAXLEN+1];
+ int mode;
+ char *err;
+
+ mode=M_NONE;
+
+ if (!(fp=fopen(fn,"r")))
+ GFX_exit(EXIT_FAILURE,"Couldn't open config file %s\n",fn);
+
+ while((line=GetLine(fp)))
+ {
+ strcpy(orig,line);
+ err=NULL;
+
+ if (*line=='%')
+ {
+ mode=StrToInt(mode_list,line,M_NONE);
+
+ switch(mode)
+ {
+ case M_SECTOR_STYLES:
+ StartSectorStyles();
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ switch(mode)
+ {
+ case M_THING_CLASSES:
+ {
+ char *p[2];
+
+ p[0]=strtok(line,"|");
+
+ if (p[0])
+ p[1]=strtok(NULL,"|");
+
+ if (p[1])
+ ThingNewClass(p[0],ATOI(p[1]));
+ else
+ err="THING_CLASSES";
+
+ break;
+ }
+
+ case M_LINEDEF_CLASSES:
+ LinedefNewClass(line);
+ break;
+
+ case M_SECTOR_CLASSES:
+ SectorNewClass(line);
+ break;
+
+ case M_THING_TYPES:
+ {
+ char *p[5];
+ int f;
+
+ p[0]=strtok(line,"|");
+
+ for(f=1;(f<5)&&(p[f-1]);f++)
+ p[f]=strtok(NULL,"|");
+
+ if (p[4])
+ ThingAdd(p[0],p[1],ATOI(p[2]),ATOI(p[3]),
+ (load_sprites ? DecodeGraphicsLump(p[4]) :
+ NULL));
+ else
+ err="THING_TYPES";
+
+ break;
+ }
+
+ case M_SECTOR_TYPES:
+ {
+ char *p[4];
+ int f;
+
+ p[0]=strtok(line,"|");
+
+ for(f=1;(f<4)&&(p[f-1]);f++)
+ p[f]=strtok(NULL,"|");
+
+ if (p[3])
+ SectorAdd(p[0],ATOI(p[1]),p[2],p[3]);
+ else
+ err="SECTOR_TYPES";
+
+ break;
+ }
+
+ case M_LINEDEF_TYPES:
+ {
+ char *p[3];
+
+ p[0]=strtok(line,"|");
+
+ if (p[0])
+ p[1]=strtok(NULL,"|");
+
+ if (p[1])
+ p[2]=strtok(NULL,"|");
+
+ if (p[2])
+ LinedefAdd(p[0],p[2],ATOI(p[1]));
+ else
+ err="LINEDEF_TYPES";
+
+ break;
+ }
+
+ case M_LINEDEF_FLAGS:
+ {
+ char *p[3];
+ int f;
+
+ p[0]=strtok(line,"|");
+
+ if (p[0])
+ p[1]=strtok(NULL,"|");
+
+ if (p[1])
+ p[2]=strtok(NULL,"|");
+
+ f=ATOI(p[0]);
+
+ if ((f>=0)&&(f<=15)&&(p[2]))
+ LinedefFlag(f,p[1],*p[2]);
+ else
+ err="LINEDEF_FLAGS";
+
+ break;
+ }
+
+ case M_INCLUDE:
+ {
+ char s[PATH_MAX];
+
+ strcpy(s,line);
+ DoLoadConfig(s);
+ break;
+ }
+
+ case M_THING_FLAGS:
+ {
+ char *p[3];
+ int f;
+
+ p[0]=strtok(line,"|");
+
+ if (p[0])
+ p[1]=strtok(NULL,"|");
+
+ if (p[1])
+ p[2]=strtok(NULL,"|");
+
+ f=ATOI(p[0]);
+
+ if ((f>=0)&&(f<=15)&&(p[2]))
+ ThingFlag(f,p[1],p[2]);
+ else
+ err="THING_FLAGS";
+
+ break;
+ }
+
+ case M_LINEDEF_DEFAULTS:
+ {
+ int flags;
+ char *p[2];
+
+ if (side2_bit==-1)
+ GFX_exit
+ (EXIT_FAILURE,
+ "LINEDEF_DEFAULTS appeared before "
+ "LINEDEF_FLAGS_EXTRA\n");
+
+ p[0]=strtok(line,"|");
+
+ if (p[0])
+ p[1]=strtok(NULL,"|");
+
+ if (p[1])
+ {
+ flags=ATOI(p[1]);
+ AddLinedefType(p[0],flags,flags&side2_mask);
+ }
+ else
+ err="LINEDEF_DEFAULTS";
+
+ break;
+ }
+
+ case M_SECTOR_STYLES:
+ {
+ char *p[7];
+ int f;
+
+ p[0]=strtok(line,"|");
+
+ for(f=1;(f<7)&&(p[f-1]);f++)
+ p[f]=strtok(NULL,"|");
+
+ if (p[6])
+ AddSectorStyle(p[1],ATOI(p[0]),p[2],p[3],
+ p[4],p[5],p[6]);
+ else
+ err="SECTOR_STYLES";
+
+ break;
+ }
+
+ case M_LINEDEF_FLAGS_EXTRA:
+ {
+ char *p[4];
+ int f;
+
+ p[0]=strtok(line,"|");
+
+ for(f=1;(f<4)&&(p[f-1]);f++)
+ p[f]=strtok(NULL,"|");
+
+ if (p[3])
+ {
+ side2_bit=ATOI(p[0]);
+ side2_mask=1<<side2_bit;
+
+ block_bit=ATOI(p[1]);
+ block_mask=1<<block_bit;
+
+ upper_peg_bit=ATOI(p[2]);
+ upper_peg_mask=1<<upper_peg_bit;
+
+ lower_peg_bit=ATOI(p[3]);
+ lower_peg_mask=1<<lower_peg_bit;
+ }
+ else
+ err="LINEDEF_FLAGS_EXTRA";
+
+ break;
+ }
+
+ case M_EMPTY_TEXTURE_NAME:
+ strncpy(empty_texture,line,sizeof(empty_texture)-1);
+ empty_texture[sizeof(empty_texture)-1]=0;
+ break;
+
+ case M_NORMAL_TYPES:
+ {
+ char *p[2];
+
+ p[0]=strtok(line,"|");
+
+ if (p[0])
+ p[1]=strtok(NULL,"|");
+
+ if (p[1])
+ {
+ normal_sector=ATOI(p[0]);
+ normal_linedef=ATOI(p[1]);
+ }
+ else
+ err="NORMAL_TYPES";
+
+ break;
+ }
+
+ case M_LINEDEF_CHECK_DEFAULT:
+ strncpy(linedef_check_default,line,
+ sizeof(linedef_check_default)-1);
+ linedef_check_default[sizeof(linedef_check_default)-1]=0;
+ break;
+
+ case M_NONE:
+ break;
+ }
+
+ if (err)
+ GFX_exit
+ (EXIT_FAILURE,
+ "%s: section %s\nError in line '%s'\n",fn,err,orig);
+ }
+
+ fclose(fp);
+}
+
+
+/* ------------------------------ EXPORTED FUNCTIONS
+*/
+
+void LoadGlobalsPart1(void)
+{
+ INI_Load("vidoom.ini");
+ INI_GetTable(part1_ini,INI_TAB_SIZE(part1_ini));
+}
+
+
+void LoadGlobalsPart2(void)
+{
+ INI_GetTable(part2_ini,INI_TAB_SIZE(part2_ini));
+
+ switch(game)
+ {
+ case DOOM:
+ INI_GetTable(doom_ini,INI_TAB_SIZE(doom_ini));
+ game_name="Doom - Knee Deep in The Dead";
+ break;
+ case ULTIMATE_DOOM:
+ INI_GetTable(ult_doom_ini,INI_TAB_SIZE(ult_doom_ini));
+ game_name="Utlimate Doom - Thy Flesh Consumed";
+ break;
+ case DOOM_2:
+ INI_GetTable(doom_2_ini,INI_TAB_SIZE(doom_2_ini));
+ game_name="Doom 2 - Hell On Earth";
+ break;
+ case FINAL_TNT:
+ INI_GetTable(tnt_ini,INI_TAB_SIZE(tnt_ini));
+ game_name="Final Doom - TNT:Evilution";
+ break;
+ case FINAL_PLUTONIA:
+ INI_GetTable(plut_ini,INI_TAB_SIZE(plut_ini));
+ game_name="Final Doom - The Plutonia Experiment";
+ break;
+ case ZDOOM:
+ INI_GetTable(zdoom_ini,INI_TAB_SIZE(zdoom_ini));
+ game_name="ZDoom/BOOM extensions to Doom";
+ break;
+ }
+
+ CheckVals();
+}
+
+
+void SaveGlobals(void)
+{
+ INI_PutTable(part1_ini,INI_TAB_SIZE(part1_ini));
+ INI_PutTable(part2_ini,INI_TAB_SIZE(part2_ini));
+
+ switch(game)
+ {
+ case DOOM:
+ INI_PutTable(doom_ini,INI_TAB_SIZE(doom_ini));
+ break;
+ case ULTIMATE_DOOM:
+ INI_PutTable(ult_doom_ini,INI_TAB_SIZE(ult_doom_ini));
+ break;
+ case DOOM_2:
+ INI_PutTable(doom_2_ini,INI_TAB_SIZE(doom_2_ini));
+ break;
+ case FINAL_TNT:
+ INI_PutTable(tnt_ini,INI_TAB_SIZE(tnt_ini));
+ break;
+ case FINAL_PLUTONIA:
+ INI_PutTable(plut_ini,INI_TAB_SIZE(plut_ini));
+ break;
+ case ZDOOM:
+ INI_PutTable(zdoom_ini,INI_TAB_SIZE(zdoom_ini));
+ break;
+ }
+
+ INI_Save();
+}
+
+
+void LoadConfig(void)
+{
+ DoLoadConfig(config_file);
+}
+
+
+/* END OF FILE */
+