From 0f12083fdb14ae813e419500918b95cb83070586 Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 9 Jun 2011 13:57:32 +0000 Subject: Added copies of old numbered releases. --- sectors.c | 318 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 sectors.c (limited to 'sectors.c') diff --git a/sectors.c b/sectors.c new file mode 100644 index 0000000..0c6ce40 --- /dev/null +++ b/sectors.c @@ -0,0 +1,318 @@ +/* + + 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 + + ------------------------------------------------------------------------- + + Handles definition and storage of the supported SECTORS + +*/ +static const char rcs_id[]="$Id$"; + +#include "config.h" +#include "globals.h" + +#include "sectors.h" +#include "mem.h" +#include "list.h" +#include "map.h" + + +/* ---------------------------------------- TYPES AND VARS +*/ +typedef struct + { + char *name; + } + SectorClass; + +typedef struct + { + int class; + int id; + char *long_name; + char *short_name; + } SectorInfo; + +typedef struct + { + int flags; + char *name; + DirName upper; + DirName middle; + DirName lower; + DirName floor; + DirName ceiling; + } SectorStyle; + +static int no_classes=0; + +static Map sect_class=NULL; +static List sect_list=NULL; +static Map sect_style=NULL; + +static PLAT_MENU *menu=NULL; +static PLAT_PICKLIST **picklist=NULL; + +static char **sect_style_plist=NULL; + + +/* ---------------------------------------- PRIVATE FUNCTIONS +*/ +static PLAT_PICKLIST *SectorPicklist(int class) +{ + SectorInfo *si; + Iterator i; + int no; + int f; + + if (picklist[class]) + return(picklist[class]); + + no=0; + i=ListIterator(sect_list); + + while(i) + { + si=IteratorData(i); + + if (si->class==class) + no++; + + i=IteratorNext(i); + } + + picklist[class]=Grab(sizeof(PLAT_PICKLIST)*(no+1)); + + i=ListIterator(sect_list); + + f=0; + while(i) + { + si=IteratorData(i); + + if (si->class==class) + { + picklist[class][f].text=si->long_name; + picklist[class][f].client_index=si->id; + f++; + } + + i=IteratorNext(i); + } + + picklist[class][f].text=NULL; + + return(picklist[class]); +} + + +/* ---------------------------------------- EXPORTED FUNCTIONS +*/ +void SectorNewClass(char *class) +{ + SectorClass c; + + if (!sect_class) + sect_class=MapNew(sizeof(SectorClass)); + + c.name=Strdup(class); + + MapAdd(sect_class,no_classes++,&c); +} + + +void SectorAdd(char *class,int id,char *long_name,char *short_name) +{ + SectorInfo *s; + int i_class; + int f; + + if (!sect_list) + sect_list=ListNew(sizeof(SectorInfo)); + + s=Grab(sizeof(SectorInfo)); + + i_class=-1; + + for(f=0;fname,class)) + i_class=f; + } + + if (i_class==-1) + i_class=0; + + s->class=i_class; + s->id=id; + s->long_name=Strdup(long_name); + s->short_name=Strdup(short_name); + ListAppend(sect_list,s); +} + + +int SelectSector(void) +{ + int class; + int f; + int x,y; + + if (!menu) + { + menu=Grab(sizeof(PLAT_MENU)*(no_classes+1)); + picklist=Grab(sizeof(PLAT_IMG_PICKLIST *)*(no_classes+1)); + + for(f=0;fname; + menu[f].client_index=f; + } + + for(f=0;fid==id) + { + IteratorClear(i); + return(si->short_name); + } + + i=IteratorNext(i); + } + + return("UNKNOWN"); +} + + +void StartSectorStyles(void) +{ + SectorStyle *s; + int f; + + if (!sect_style) + { + for(f=0;fname); + } + + sect_style=MapNew(sizeof(SectorStyle)); + } + else + MapEmpty(sect_style); +} + + +void AddSectorStyle(char *name, int flags, DirName upper, DirName middle, + DirName lower, DirName floor, DirName ceiling) +{ + SectorStyle s; + + s.flags=flags; + s.name=Strdup(name); + strcpy(s.upper,upper); + strcpy(s.middle,middle); + strcpy(s.lower,lower); + strcpy(s.floor,floor); + strcpy(s.ceiling,ceiling); + + MapAdd(sect_style,-1,&s); +} + + +int ChooseSectorStyle(int *flags, DirName upper,DirName middle,DirName lower, + DirName floor,DirName ceiling) +{ + SectorStyle *s; + int f; + + if (!sect_style_plist) + { + sect_style_plist=Grab(sizeof(char *)*(MapSize(sect_style)+1)); + + for(f=0;fname; + } + + sect_style_plist[MapSize(sect_style)]=NULL; + } + + f=GUI_picklist("SECTOR STYLE",sect_style_plist); + + if (f!=-1) + { + s=MapElem(sect_style,f); + *flags=s->flags; + strcpy(lower,s->lower); + strcpy(middle,s->middle); + strcpy(upper,s->upper); + strcpy(floor,s->floor); + strcpy(ceiling,s->ceiling); + return(TRUE); + } + else + return(FALSE); +} + +int NoSectorStyles(void) +{ + return(MapSize(sect_style)); +} + + +/* END OF FILE */ -- cgit v1.2.3