/* Static funcs */
static void draw_main_menu(void)
{
+ wclear(fullscreen_window);
mvwprintw(fullscreen_window, 1, 23, "----====< Victrix Abyssi >====----\n");
mvwprintw(fullscreen_window, 3, 25, "A roguelike game by Martin Read\n");
mvwprintw(fullscreen_window, 10, 25, "S)tart new game\n");
wmove(message_window, 0, 0);
map_updated = FALSE;
status_updated = FALSE;
- draw_main_menu();
- run_main_menu();
- if (!game_finished)
+ do
{
- status_updated = 1;
- map_updated = 1;
- hard_redraw = 1;
- display_update();
- // WIP launch the game logic.
- }
+ draw_main_menu();
+ run_main_menu();
+ if (!game_finished)
+ {
+ status_updated = 1;
+ map_updated = 1;
+ hard_redraw = 1;
+ display_update();
+ main_loop();
+ }
+ } while (1);
return 0;
}
noecho();
new_game(name);
done = true;
+ wclear(message_window);
+ wmove(message_window, 0, 0);
show_game_view();
break;
case 'c':
// TODO implement loading properly.
{
int i;
+ wclear(message_window);
+ wmove(message_window, 0, 0);
i = load_game();
if (i != -1)
{
else
{
mvwprintw(fullscreen_window, 14, 30, "No saved game found.\n");
+ update_panels();
+ doupdate();
}
}
break;
case 'q':
case 'Q':
- done = true;
- game_finished = true;
- break;
+ endwin();
+ exit(0);
}
} while (!done);
if (!game_finished)
rebuild_mapobjs();
rebuild_mapmons();
fclose(fp);
+ game_finished = false;
look_around_you();
notify_load_complete();
int i = unlinkat(datadir_fd, "victrix-abyssi.sav", 0);
#include <deque>
#include <basedir.h>
-static void main_loop(void);
bool game_finished;
int32_t game_tick;
bool wizard_mode = WIZARD_MODE;
+void game_cleanup(void)
+{
+ depth = 0;
+ game_tick = 0;
+ level_cleanup();
+ player_cleanup();
+}
+
void new_game(char const *name)
{
+ game_finished = false;
+ depth = 1;
+ game_tick = 0;
u_init(name);
make_new_level();
}
game_tick++;
notify_tick();
}
+ game_cleanup();
}
/*! \brief main()
#include <string.h>
Level lvl;
-int depth = 1;
+int depth;
void drop_all_chunks(Level *l)
{
return ((val << clockwise_steps) | ((val & 0xf) >> (4 - clockwise_steps))) & 0xf;
}
+void level_cleanup(void)
+{
+ int i;
+ for (i = 0; i < MONSTERS_IN_PLAY; ++i)
+ {
+ monsters[i].used = false;
+ }
+ for (i = 0; i < OBJECTS_IN_PLAY; ++i)
+ {
+ objects[i].used = false;
+ objects[i].with_you = false;
+ }
+ drop_all_chunks(&lvl);
+}
+
/* map.cc */
// vim:cindent:ts=8:sw=4:expandtab
extern enum level_theme current_theme;
extern enum level_layout current_layout;
-extern void leave_level(void);
-extern void make_new_level(void);
-extern void build_level(void);
-extern void populate_level(void);
-extern void inject_player(Level_key from);
-extern void look_around_you(void);
-extern bool terrain_is_opaque(Terrain terr);
-extern bool terrain_blocks_beings(Terrain terr);
-extern bool terrain_blocks_missiles(Terrain terr);
-extern void serialize_level(FILE *fp, Level const *l);
-extern void deserialize_level(FILE *fp, Level *l);
+void leave_level(void);
+void make_new_level(void);
+void build_level(void);
+void populate_level(void);
+void inject_player(Level_key from);
+void look_around_you(void);
+bool terrain_is_opaque(Terrain terr);
+bool terrain_blocks_beings(Terrain terr);
+bool terrain_blocks_missiles(Terrain terr);
+void serialize_level(FILE *fp, Level const *l);
+void deserialize_level(FILE *fp, Level *l);
+
+void level_cleanup(void);
#endif
/* map.h */
int armour; //!< Object handle of currently equipped armour.
int ring; //!< Object handle of currently equipped ring.
int sympathy[TOTAL_FELL_POWERS]; //!< Level of alignment with fell powers
+ /* Methods only after here plzkthx */
bool resists(Damtyp dtype) const; //!< Does player resist this Damtyp?
bool martial(void) const //!< Is player significantly influenced by iron?
{ return sympathy[FePo_iron] > 10; }
/* XXX u.c data and funcs */
extern Player u;
-extern void u_init(char const *name);
-extern void write_char_dump(void);
-extern int do_death(Death d, char const *what);
-extern void heal_u(int amount, int boost, int loud);
-extern int damage_u(int amount, Death d, char const *what);
-extern int gain_body(int amount);
-extern int gain_agility(int amount);
-extern int drain_body(int amount, char const *what, int permanent);
-extern int drain_agility(int amount, char const *what, int permanent);
-extern void gain_experience(int amount);
-extern int lev_threshold(int level);
-extern Action_cost move_player(Offset delta);
-extern void reloc_player(Coord c);
-extern void recalc_defence(void);
-extern Pass_fail teleport_u(void);
-extern void update_player(void);
+
+void u_init(char const *name);
+void write_char_dump(void);
+int do_death(Death d, char const *what);
+void heal_u(int amount, int boost, int loud);
+int damage_u(int amount, Death d, char const *what);
+int gain_body(int amount);
+int gain_agility(int amount);
+int drain_body(int amount, char const *what, int permanent);
+int drain_agility(int amount, char const *what, int permanent);
+void gain_experience(int amount);
+int lev_threshold(int level);
+Action_cost move_player(Offset delta);
+void reloc_player(Coord c);
+void recalc_defence(void);
+Pass_fail teleport_u(void);
+void update_player(void);
inline bool empty_handed(void) { return u.weapon == NO_OBJ; }
-extern bool wielding_melee_weapon(void);
-extern bool wielding_ranged_weapon(void);
+bool wielding_melee_weapon(void);
+bool wielding_ranged_weapon(void);
+void player_cleanup(void);
#endif
/* player.hh */
extern void *saved_state_buffer;
extern int saved_state_size;
//extern uint32_t rng(void);
-extern void rng_init(void);
-extern int zero_die(int sides); /* 0..n-1 */
-extern int one_die(int sides); /* 1..n */
-extern int dice(int count, int sides);
-extern int exc_flat(int lower, int upper); /* l+1 ... u-1 */
-extern int inc_flat(int lower, int upper); /* l ... u */
-extern Coord inc_boxed(Coord topleft, Coord botright);
-extern Coord exc_boxed(Coord topleft, Coord botright);
+void rng_init(void);
+int zero_die(int sides); /* 0..n-1 */
+int one_die(int sides); /* 1..n */
+int dice(int count, int sides);
+int exc_flat(int lower, int upper); /* l+1 ... u-1 */
+int inc_flat(int lower, int upper); /* l ... u */
+Coord inc_boxed(Coord topleft, Coord botright);
+Coord exc_boxed(Coord topleft, Coord botright);
+Offset random_step(void);
/*! \brief An instance of Bob Jenkins' "small noncryptographic PRNG"
*
return Cost_none;
}
+void player_cleanup(void)
+{
+ int i;
+ memset(u.sympathy, '\0', sizeof u.sympathy);
+ memset(u.resistances, '\0', sizeof u.resistances);
+ u.experience = u.level = 0;
+ u.body = u.agility = u.bdam = u.adam = 0;
+ memset(u.name, '\0', sizeof u.name);
+ u.name[0] = '\0';
+ u.pos.y = u.pos.x = 0;
+ u.hpmax = u.hpcur = 0;
+ u.food = 0;
+ u.leadfoot = u.protection = u.withering = u.armourmelt = 0;
+ u.level = 0;
+ u.weapon = u.armour = u.ring = NO_OBJ;
+ for (i = 0; i < 19; ++i)
+ {
+ u.inventory[i] = NO_OBJ;
+ }
+}
+
/* u.cc */
// vim:cindent:expandtab
#endif
/* XXX main.c data and funcs */
-extern Offset random_step(void);
-extern Action_cost do_player_action(Action *act);
extern bool game_finished;
extern int game_tick;
extern bool wizard_mode;
-extern void new_game(char const *name);
+Action_cost do_player_action(Action *act);
+void new_game(char const *name);
+void main_loop(void);
/* XXX misc.c data and funcs */
extern char const *damtype_names[DT_COUNT];