#include "vars.h" #include "pline.h" #include "structs.h" #include "gates.h" /* * There are four unique gates and eight elemental-plane gates. We * store all their LOC pointers here. The gate_elem_* arrays are * indexed by level number (L_EARTH, L_AIR, etc), whence the offset * definitions. gate_hell is non-static for the benefit of * filldungeon(). */ LOC *gate_dungeon; LOC *gate_uworld_dungeon; LOC *gate_uworld_hell; LOC *gate_hell; LOC *gate_elem_dungeon_[L__NELEM]; LOC *gate_elem_uworld_[L__NELEM]; void makegate(LOC *lc, GATETYPE t) { LOC **arr; switch (t) { case LOC_GATE_DUNGEON: gate_dungeon = lc; break; case LOC_GATE_UWORLD_DUNGEON: gate_uworld_dungeon = lc; break; case LOC_GATE_UWORLD_HELL: gate_uworld_hell = lc; break; case LOC_GATE_HELL: gate_hell = lc; break; case LOC_GATE_ELEM_DUNGEON: arr = gate_elem_dungeon; if (0) { case LOC_GATE_ELEM_UWORLD: arr = gate_elem_uworld; } if ((lc->on->levelno < L__FIRSTELEM) || (lc->on->levelno >= L__FIRSTELEM+L__NELEM)) panic("creating gate on impossible elemental plane %d",lc->on->levelno); arr[lc->on->levelno] = lc; break; default: panic("creating gate of impossible type %d",(int)t); break; } lc->type = LOC_GATE; lc->gatetype = t; } LOC *gate_other_end(LOC *lc, GATEHOW how) { int i; if (lc->type != LOC_GATE) panic("gate_other_end on non-gate"); switch (lc->gatetype) { default: panic("impossible gate type %d",(int)lc->gatetype); break; case LOC_GATE_DUNGEON: switch (how) { default: panic("impossible GATEHOW %d",(int)how); break; case GH_DEBUG: case GH_PLAYER: return(gate_elem_dungeon[elem_order[0]]); break; case GH_E_EARTH: return(gate_elem_dungeon[L_EARTH]); break; case GH_E_AIR: return(gate_elem_dungeon[L_AIR]); break; case GH_E_FIRE: return(gate_elem_dungeon[L_FIRE]); break; case GH_E_WATER: return(gate_elem_dungeon[L_WATER]); break; case GH_REGULAR: return(gate_uworld_dungeon); break; } break; case LOC_GATE_UWORLD_DUNGEON: switch (how) { default: panic("impossible GATEHOW %d",(int)how); break; case GH_DEBUG: case GH_PLAYER: return(gate_elem_uworld[elem_order[L__NELEM-1]]); break; case GH_E_EARTH: return(gate_elem_uworld[L_EARTH]); break; case GH_E_AIR: return(gate_elem_uworld[L_AIR]); break; case GH_E_FIRE: return(gate_elem_uworld[L_FIRE]); break; case GH_E_WATER: return(gate_elem_uworld[L_WATER]); break; case GH_REGULAR: return(gate_dungeon); break; } break; case LOC_GATE_UWORLD_HELL: return(gate_hell); break; case LOC_GATE_HELL: return(gate_uworld_hell); break; case LOC_GATE_ELEM_DUNGEON: switch (how) { default: panic("impossible GATEHOW %d",(int)how); break; case GH_DEBUG: case GH_PLAYER: if ((lc->on->levelno < L__FIRSTELEM) || (lc->on->levelno >= L__FIRSTELEM+L__NELEM)) panic("getting other end of ELEM_DUNGEON gate on impossible level %d",lc->on->levelno); i = elem_order_i[lc->on->levelno]; return((i>0)?gate_elem_uworld[elem_order[i-1]]:gate_dungeon); break; case GH_E_EARTH: if (lc->on->levelno != L_EARTH) panic("GH_E_EARTH gate off non-earth plane %d",lc->on->levelno); return(gate_dungeon); break; case GH_E_AIR: if (lc->on->levelno != L_AIR) panic("GH_E_AIR gate off non-air plane %d",lc->on->levelno); return(gate_dungeon); break; case GH_E_FIRE: if (lc->on->levelno != L_FIRE) panic("GH_E_FIRE gate off non-fire plane %d",lc->on->levelno); return(gate_dungeon); break; case GH_E_WATER: if (lc->on->levelno != L_WATER) panic("GH_E_WATER gate off non-water plane %d",lc->on->levelno); return(gate_dungeon); break; case GH_REGULAR: panic("GH_REGULAR ELEM_DUNGEON gate"); break; } break; case LOC_GATE_ELEM_UWORLD: switch (how) { default: panic("impossible GATEHOW %d",(int)how); break; case GH_DEBUG: case GH_PLAYER: if ((lc->on->levelno < L__FIRSTELEM) || (lc->on->levelno >= L__FIRSTELEM+L__NELEM)) panic("getting other end of ELEM_DUNGEON gate on impossible level %d",lc->on->levelno); i = elem_order_i[lc->on->levelno]; return((ion->levelno != L_EARTH) panic("GH_E_EARTH gate off non-earth plane %d",lc->on->levelno); return(gate_uworld_dungeon); break; case GH_E_AIR: if (lc->on->levelno != L_AIR) panic("GH_E_AIR gate off non-air plane %d",lc->on->levelno); return(gate_uworld_dungeon); break; case GH_E_FIRE: if (lc->on->levelno != L_FIRE) panic("GH_E_FIRE gate off non-fire plane %d",lc->on->levelno); return(gate_uworld_dungeon); break; case GH_E_WATER: if (lc->on->levelno != L_WATER) panic("GH_E_WATER gate off non-water plane %d",lc->on->levelno); return(gate_uworld_dungeon); break; case GH_REGULAR: panic("GH_REGULAR ELEM_UWORLD gate"); break; } break; } }