From 1f721ed03ca07859f86b431e0d28f69ac6d80fae Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 25 Aug 2011 09:01:28 +0000 Subject: [PATCH] - [+] bug in movement speed display for monsters - [+] bug: curtime getting past 23:59. need it to wrap around. * [+] track # days spent. - [+] need to save gametime! --- defs.h | 1 + io.c | 6 +++--- lf.c | 1 + nexus.c | 19 ++++++++++++++++--- objects.c | 4 ++++ save.c | 22 +++++++++++++++++++++- save.h | 2 ++ 7 files changed, 48 insertions(+), 7 deletions(-) diff --git a/defs.h b/defs.h index 87f4df2..3e7580a 100644 --- a/defs.h +++ b/defs.h @@ -291,6 +291,7 @@ #define ANYROOM (-9770) #define FALLTHRU (-8765) // for walkdambp #define TICK_INTERVAL (20) +#define DAYSECS (86400) // # seconds in a day diff --git a/io.c b/io.c index 9407ec5..4a32316 100644 --- a/io.c +++ b/io.c @@ -8285,9 +8285,9 @@ void showlfstats(lifeform_t *lf, int showall) { if (lorelev >= PR_NOVICE) unsetcol(mainwin, lorecol); } - getspeednameshort(getactspeed(player), actbuf); - getspeednameshort(getmovespeed(player), movebuf); - if (!strcmp(actbuf, movebuf)) { + getspeednameshort(getactspeed(lf), actbuf); + getspeednameshort(getmovespeed(lf), movebuf); + if (streq(actbuf, movebuf)) { sprintf(buf, "%s", actbuf); capitalise(buf); } else { diff --git a/lf.c b/lf.c index bac53d3..17555eb 100644 --- a/lf.c +++ b/lf.c @@ -15061,6 +15061,7 @@ void initskills(void) { addskilldesc(SK_SS_MODIFICATION, PR_EXPERT, "Allows you to cast Modification spells up to level 5.", B_FALSE); addskilldesc(SK_SS_MODIFICATION, PR_MASTER, "Allows you to cast Modification spells up to level 6.", B_FALSE); addskill(SK_SS_MENTAL, "Psionics", "Boosts casting of spells from this school.", 50); + addskilldesc(SK_SS_MENTAL, PR_INEPT, "- Each rank gives you a 10%% chance to learn a new psionic ability when levelling up.", B_FALSE); addskilldesc(SK_SS_MENTAL, PR_NOVICE, "Allows you to cast Psionic spells up to level 1.", B_FALSE); addskilldesc(SK_SS_MENTAL, PR_BEGINNER, "Allows you to cast Psionic spells up to level 2.", B_FALSE); addskilldesc(SK_SS_MENTAL, PR_ADEPT, "Allows you to cast Psionic spells up to level 3.", B_FALSE); diff --git a/nexus.c b/nexus.c index 2f92de5..8e3287c 100644 --- a/nexus.c +++ b/nexus.c @@ -85,8 +85,10 @@ int obdb = B_FALSE; enum GAMEMODE gamemode = GM_FIRST; -long curtime = 0; -long timeleft = 0; +long curtime = 0; // # current game clock (in seconds) +long gamedays = 0; // # game days passed since start of game +long gamesecs = 0; // # game seconds passed since start of game +long timeleft = 0; // # secs remaining for which we need to process events extern int statdirty; @@ -306,7 +308,7 @@ int main(int argc, char **argv) { getplayernamefull(pname); sprintf(welcomemsg, "Greetings %s, welcome to %snexus!", pname, newworld ? "the new " : ""); // 00:00 - 23:59 - curtime = rnd(0,86399); + curtime = rnd(0,DAYSECS-1); } else { sprintf(welcomemsg, "Welcome back!"); @@ -1534,6 +1536,17 @@ void timeeffectsworld(map_t *map, int updategametime) { if (updategametime) { // inc game time curtime += firstlftime; + // don't let it get higher than 23:59 + while (curtime >= DAYSECS) { + curtime -= DAYSECS; + } + + // inc total gametime passed + gamesecs += firstlftime; + while (gamesecs >= DAYSECS) { + gamesecs -= DAYSECS; + gamedays++; + } } if (db) dblog("cur time is %ld\n",curtime); diff --git a/objects.c b/objects.c index c48c370..f9e6694 100644 --- a/objects.c +++ b/objects.c @@ -8803,18 +8803,21 @@ void initobjects(void) { addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL); addflag(lastot->flags, F_OBHP, 3, 3, NA, NULL); + addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); addot(OT_PIRATEHAT, "tricorne", "A three cornered hat with a skull and crossbones emblem.", MT_CLOTH, 1, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_UNCOMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL); addflag(lastot->flags, F_OBHP, 2, 2, NA, NULL); addflag(lastot->flags, F_SCARY, 2, NA, NA, NULL); + addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); addot(OT_CAP, "cap", "Close-fitting headwear with a short shade visor at the front.", MT_CLOTH, 1, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_COMMON, NULL); addflag(lastot->flags, F_RARITY, H_FOREST, 100, RR_COMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); addflag(lastot->flags, F_ARMOURRATING, 1, NA, NA, NULL); addflag(lastot->flags, F_OBHP, 3, 3, NA, NULL); + addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); addot(OT_GASMASK, "gas mask", "A full face mask which protects the wearer from toxic gasses.", MT_METAL, 3.5, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_DUNGEON, 75, RR_UNCOMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); @@ -8823,6 +8826,7 @@ void initobjects(void) { addflag(lastot->flags, F_OBHP, 10, 10, NA, NULL); addflag(lastot->flags, F_EQUIPCONFER, F_DTIMMUNE, DT_POISONGAS, NA, NULL); addflag(lastot->flags, F_EQUIPCONFER, F_VISRANGEMOD, -5, NA, NULL); + addflag(lastot->flags, F_NOQUALITY, B_TRUE, NA, NA, NULL); addot(OT_HELM, "helmet", "A plain metal helmet.", MT_METAL, 2, OC_ARMOUR, SZ_SMALL); addflag(lastot->flags, F_RARITY, H_DUNGEON, 100, RR_COMMON, NULL); addflag(lastot->flags, F_GOESON, BP_HEAD, NA, NA, NULL); diff --git a/save.c b/save.c index 63d0e9f..7a8c705 100644 --- a/save.c +++ b/save.c @@ -25,6 +25,8 @@ extern knowledge_t *knowledge; extern region_t *firstregion,*lastregion; extern regionoutline_t *firstregionoutline,*lastregionoutline; +extern long curtime, gamedays, gamesecs; + extern enum GAMEMODE gamemode; int loadall(void) { @@ -40,13 +42,15 @@ int loadall(void) { return B_TRUE; } - // load region outlines first. + + // load region outlines if (loadregions()) { // this isn't an error - just means no savegames if (db) dblog("No region data found."); return B_FALSE; } + // for each map file in directory while ((ent = readdir(dir)) != NULL) { char *p; @@ -692,6 +696,11 @@ int loadsavegame(void) { printf("Error opening savegame file '%s'",ent->d_name); exit(1); } + // load world data + if (loadworlddata(f)) { + printf("Error load world data from file '%s'", ent->d_name); + exit(1); + } if (!loadlf(f, NULL)) { printf("Error loading player from file '%s'",ent->d_name); exit(1); @@ -725,6 +734,10 @@ int savevars(FILE *f) { return B_FALSE; } +int loadworlddata(FILE *f) { + fscanf(f, "timedata:%ld,%ld,%ld\n",&curtime,&gamedays,&gamesecs); + return B_FALSE; +} int saveflagpile(FILE *f, flagpile_t *fp) { flag_t *fl; @@ -811,6 +824,7 @@ int savegame(void) { FILE *f; char buf[BUFLEN]; int rv; + rv = saveregions(); if (rv) { msg("Could not save region data."); @@ -831,6 +845,7 @@ int savegame(void) { msg("Could not open save file!"); return B_TRUE; } + saveworlddata(f); savelf(f, player); saveknowledge(f); savevars(f); @@ -1016,6 +1031,11 @@ int saveregions(void) { return B_FALSE; } +int saveworlddata(FILE *f) { + fprintf(f, "timedata:%ld,%ld,%ld\n",curtime,gamedays,gamesecs); + return B_FALSE; +} + int showhiscores(lifeform_t *lf, int min, int max) { sqlite3 *db; int rc; diff --git a/save.h b/save.h index 0cb8741..289b9ca 100644 --- a/save.h +++ b/save.h @@ -8,6 +8,7 @@ map_t *loadmap(char *basefile); int loadob(FILE *f, obpile_t *op, long *id); int loadregions(void); int loadsavegame(void); +int loadworlddata(FILE *f); int saveflagpile(FILE *f, flagpile_t *fp); int saveknowledge(FILE *f); int savelf(FILE *f, lifeform_t *l); @@ -15,5 +16,6 @@ int savegame(void); int savemap(map_t *m); int saveob(FILE *f, object_t *o); int saveregions(void); +int saveworlddata(FILE *f); int showhiscores(lifeform_t *lf, int min, int max); int writehiscore(lifeform_t *lf, int *rank);