Merge branch 'master' into feature/unittesting
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -71,6 +71,8 @@ lib/plrobjs/index
|
|||||||
/lib/etc/last
|
/lib/etc/last
|
||||||
# or mail
|
# or mail
|
||||||
lib/etc/plrmail
|
lib/etc/plrmail
|
||||||
|
# or time
|
||||||
|
lib/etc/time
|
||||||
|
|
||||||
# test object files, etc
|
# test object files, etc
|
||||||
src/test/depend
|
src/test/depend
|
||||||
@@ -82,4 +84,4 @@ src/test/testfile
|
|||||||
.vscode
|
.vscode
|
||||||
.project
|
.project
|
||||||
.settings
|
.settings
|
||||||
|
.cproject
|
||||||
|
|||||||
@@ -257,6 +257,9 @@ http://tbamud.com
|
|||||||
All donated areas have been added to the latest version of tbaMUD. If you
|
All donated areas have been added to the latest version of tbaMUD. If you
|
||||||
wish to donate some of your own work stop by the Builder Academy.
|
wish to donate some of your own work stop by the Builder Academy.
|
||||||
|
|
||||||
|
https://github.com/rds1983 has generated maps of all the existing areas,
|
||||||
|
and they can be found here: https://mudmapbuilder.github.io/
|
||||||
|
|
||||||
2.3. I have questions about tbaMUD. Where should I go?
|
2.3. I have questions about tbaMUD. Where should I go?
|
||||||
|
|
||||||
Stop by The Builder Academy at tbamud.com 9091 or the website at:
|
Stop by The Builder Academy at tbamud.com 9091 or the website at:
|
||||||
|
|||||||
@@ -521,15 +521,17 @@ void look_at_room(struct char_data *ch, int ignore_brief)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
send_to_char(ch, "%s", world[IN_ROOM(ch)].name);
|
send_to_char(ch, "%s", world[IN_ROOM(ch)].name);
|
||||||
|
|
||||||
send_to_char(ch, "%s\r\n", CCNRM(ch, C_NRM));
|
send_to_char(ch, "%s\r\n", CCNRM(ch, C_NRM));
|
||||||
|
|
||||||
if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ignore_brief ||
|
if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ignore_brief ||
|
||||||
ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH)) {
|
ROOM_FLAGGED(IN_ROOM(ch), ROOM_DEATH)) {
|
||||||
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch))
|
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOMAP) && can_see_map(ch))
|
||||||
str_and_map(world[target_room].description, ch, target_room);
|
str_and_map(world[target_room].description, ch, target_room);
|
||||||
|
else
|
||||||
|
send_to_char(ch, "%s", world[IN_ROOM(ch)].description);
|
||||||
}
|
}
|
||||||
|
|
||||||
send_to_char(ch, "%s", world[IN_ROOM(ch)].description);
|
|
||||||
|
|
||||||
/*autoexits */
|
/*autoexits */
|
||||||
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOEXIT))
|
if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOEXIT))
|
||||||
@@ -603,7 +605,8 @@ static void look_in_obj(struct char_data *ch, char *arg)
|
|||||||
}
|
}
|
||||||
else if (GET_OBJ_VAL(obj,1)>GET_OBJ_VAL(obj,0))
|
else if (GET_OBJ_VAL(obj,1)>GET_OBJ_VAL(obj,0))
|
||||||
send_to_char(ch, "Its contents seem somewhat murky.\r\n"); /* BUG */
|
send_to_char(ch, "Its contents seem somewhat murky.\r\n"); /* BUG */
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
char buf2[MAX_STRING_LENGTH];
|
char buf2[MAX_STRING_LENGTH];
|
||||||
amt = (GET_OBJ_VAL(obj, 1) * 3) / GET_OBJ_VAL(obj, 0);
|
amt = (GET_OBJ_VAL(obj, 1) * 3) / GET_OBJ_VAL(obj, 0);
|
||||||
sprinttype(GET_OBJ_VAL(obj, 2), color_liquid, buf2, sizeof(buf2));
|
sprinttype(GET_OBJ_VAL(obj, 2), color_liquid, buf2, sizeof(buf2));
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "sysdep.h"
|
#include "sysdep.h"
|
||||||
|
|
||||||
|
|
||||||
#define NOWHERE -1 /* nil reference for room-database */
|
#define NOWHERE -1 /* nil reference for room-database */
|
||||||
|
|
||||||
/* The cardinal directions: used as index to room_data.dir_option[] */
|
/* The cardinal directions: used as index to room_data.dir_option[] */
|
||||||
@@ -22,14 +21,17 @@
|
|||||||
#define WEST 3
|
#define WEST 3
|
||||||
#define UP 4
|
#define UP 4
|
||||||
#define DOWN 5
|
#define DOWN 5
|
||||||
|
#define NORTHWEST 6
|
||||||
|
#define NORTHEAST 7
|
||||||
|
#define SOUTHEAST 8
|
||||||
|
#define SOUTHWEST 9
|
||||||
|
|
||||||
#define NUM_OF_DIRS 6
|
#define NUM_OF_DIRS 10
|
||||||
|
|
||||||
#define CREATE(result, type, number) do {\
|
#define CREATE(result, type, number) do {\
|
||||||
if (!((result) = (type *) calloc ((number), sizeof(type))))\
|
if (!((result) = (type *) calloc ((number), sizeof(type))))\
|
||||||
{ perror("malloc failure"); abort(); } } while(0)
|
{ perror("malloc failure"); abort(); } } while(0)
|
||||||
|
|
||||||
|
|
||||||
/* Exit info: used in room_data.dir_option.exit_info */
|
/* Exit info: used in room_data.dir_option.exit_info */
|
||||||
#define EX_ISDOOR (1 << 0) /* Exit is a door */
|
#define EX_ISDOOR (1 << 0) /* Exit is a door */
|
||||||
#define EX_CLOSED (1 << 1) /* The door is closed */
|
#define EX_CLOSED (1 << 1) /* The door is closed */
|
||||||
@@ -45,7 +47,7 @@ typedef unsigned short int ush_int;
|
|||||||
typedef char bool;
|
typedef char bool;
|
||||||
typedef char byte;
|
typedef char byte;
|
||||||
|
|
||||||
typedef sh_int room_num;
|
typedef int room_num;
|
||||||
typedef sh_int obj_num;
|
typedef sh_int obj_num;
|
||||||
|
|
||||||
|
|
||||||
@@ -133,13 +135,14 @@ struct room_data {
|
|||||||
|
|
||||||
struct room_data *world = NULL; /* array of rooms */
|
struct room_data *world = NULL; /* array of rooms */
|
||||||
int top_of_world = 0; /* ref to top element of world */
|
int top_of_world = 0; /* ref to top element of world */
|
||||||
|
int rec_count = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* local functions */
|
/* local functions */
|
||||||
char *fread_string(FILE * fl, char *error);
|
char *fread_string(FILE * fl, char *error);
|
||||||
void setup_dir(FILE * fl, int room, int dir);
|
void setup_dir(FILE * fl, int room, int dir);
|
||||||
void index_boot(char *name);
|
void index_boot(int cnt, char **name);
|
||||||
void discrete_load(FILE * fl);
|
void discrete_load(FILE * fl);
|
||||||
void parse_room(FILE * fl, int virtual_nr);
|
void parse_room(FILE * fl, int virtual_nr);
|
||||||
void parse_mobile(FILE * mob_f, int nr);
|
void parse_mobile(FILE * mob_f, int nr);
|
||||||
@@ -150,7 +153,7 @@ void write_output(void);
|
|||||||
|
|
||||||
|
|
||||||
char *dir_names[] =
|
char *dir_names[] =
|
||||||
{"North", "East", "South", "West", "Up", "Down"};
|
{"North", "East", "South", "West", "Up", "Down","North West","North East","South East","South West"};
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
@@ -160,14 +163,12 @@ char *dir_names[] =
|
|||||||
/* body of the booting system */
|
/* body of the booting system */
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: %s <world-file-name>\n", argv[0]);
|
fprintf(stderr, "Usage: %s <world-file-name(s)>\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
index_boot(argv[1]);
|
|
||||||
|
|
||||||
log("Renumbering rooms.");
|
index_boot(argc,argv);
|
||||||
renum_world();
|
|
||||||
|
|
||||||
log("Writing output.");
|
log("Writing output.");
|
||||||
write_output();
|
write_output();
|
||||||
@@ -176,6 +177,21 @@ int main(int argc, char **argv)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Since the world is loaded into memory by index
|
||||||
|
* and not room number, we need to search through
|
||||||
|
* all rooms and return the correct one. This is
|
||||||
|
* used to generate door information (ie: the name)
|
||||||
|
*/
|
||||||
|
struct room_data* findRoom(int nr)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=0;i<rec_count;i++)
|
||||||
|
if (world[i].number==nr)
|
||||||
|
return &world[i];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void write_output(void)
|
void write_output(void)
|
||||||
{
|
{
|
||||||
@@ -184,11 +200,22 @@ void write_output(void)
|
|||||||
char buf[128];
|
char buf[128];
|
||||||
register int door, found;
|
register int door, found;
|
||||||
|
|
||||||
for (i = 0; i <= top_of_world; i++) {
|
for (i=0;i<rec_count;i++) {
|
||||||
|
//print the record number, but no linefeed.
|
||||||
|
fprintf(stderr, "Record: %d ",i);
|
||||||
|
if (world[i].name == NULL) {
|
||||||
|
//linefeed the prior record since we're skipping this one.
|
||||||
|
log("");
|
||||||
|
//the name is blank, which means, most likely, the record is bad as well.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sprintf(buf, "Writing %d.html", world[i].number);
|
sprintf(buf, "Writing %d.html", world[i].number);
|
||||||
log(buf);
|
log(buf);
|
||||||
sprintf(buf, "%d.html", world[i].number);
|
//for some reason, if you use %d with sprintf it rolls over like its 16bit,
|
||||||
|
//but only if you use the buffer with fopen.
|
||||||
|
//using %ld and casting to long solves this in case someone really wants
|
||||||
|
//to use negative room numbers.
|
||||||
|
sprintf(buf, "%ld.html",(long)world[i].number);
|
||||||
if (!(fl = fopen(buf, "w"))) {
|
if (!(fl = fopen(buf, "w"))) {
|
||||||
perror("opening output file");
|
perror("opening output file");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -205,10 +232,14 @@ void write_output(void)
|
|||||||
if (world[i].dir_option[door] &&
|
if (world[i].dir_option[door] &&
|
||||||
world[i].dir_option[door]->to_room != NOWHERE) {
|
world[i].dir_option[door]->to_room != NOWHERE) {
|
||||||
found = 1;
|
found = 1;
|
||||||
|
//this call gets a pointer to the room referenced by the to_room for the door.
|
||||||
|
//This fixes a lot of issues introduced with the whole 'renumbering rooms' call
|
||||||
|
//and the binary search that didn't work well.
|
||||||
|
struct room_data* to_room = findRoom(world[i].dir_option[door]->to_room);
|
||||||
fprintf(fl, "<a href = \"%d.html\"> %s to %s</a> <p>\n",
|
fprintf(fl, "<a href = \"%d.html\"> %s to %s</a> <p>\n",
|
||||||
world[world[i].dir_option[door]->to_room].number,
|
to_room->number,
|
||||||
dir_names[door],
|
dir_names[door],
|
||||||
world[world[i].dir_option[door]->to_room].name);
|
to_room->name);
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
fprintf(fl, "None!");
|
fprintf(fl, "None!");
|
||||||
@@ -231,19 +262,35 @@ int count_hash_records(FILE * fl)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void index_boot(char *name)
|
void index_boot(int cnt, char **names)
|
||||||
{
|
{
|
||||||
FILE *db_file;
|
FILE *db_file;
|
||||||
int rec_count = 0;
|
|
||||||
|
|
||||||
if (!(db_file = fopen(name, "r"))) {
|
//throw first entry away as that is the executable.
|
||||||
|
for (int i=1;i<cnt;i++) {
|
||||||
|
if (!(db_file = fopen(names[i], "r"))) {
|
||||||
perror("error opening world file");
|
perror("error opening world file");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
rec_count = count_hash_records(db_file);
|
//have to loop through files twice.
|
||||||
|
//once to get total record count
|
||||||
|
//second time to load them
|
||||||
|
rec_count += count_hash_records(db_file);
|
||||||
|
fclose(db_file);
|
||||||
|
}
|
||||||
|
sprintf(buf,"Total records: %d\n",rec_count);
|
||||||
|
log(buf);
|
||||||
|
//now that we know how many records in total
|
||||||
|
//we can create the memory structure
|
||||||
CREATE(world, struct room_data, rec_count);
|
CREATE(world, struct room_data, rec_count);
|
||||||
rewind(db_file);
|
//now loop through files and load them
|
||||||
|
for (int i=1;i<cnt;i++) {
|
||||||
|
if (!(db_file = fopen(names[i], "r"))) {
|
||||||
|
perror("error opening world file");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
discrete_load(db_file);
|
discrete_load(db_file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -257,6 +304,9 @@ void discrete_load(FILE * fl)
|
|||||||
fprintf(stderr, "Format error after room #%d\n", nr);
|
fprintf(stderr, "Format error after room #%d\n", nr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
if (*line == 'T') //Toss triggers. THey currently break this util.
|
||||||
|
continue;
|
||||||
|
|
||||||
if (*line == '$')
|
if (*line == '$')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -394,22 +444,6 @@ void setup_dir(FILE * fl, int room, int dir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* resolve all vnums into rnums in the world */
|
|
||||||
void renum_world(void)
|
|
||||||
{
|
|
||||||
register int room, door;
|
|
||||||
|
|
||||||
for (room = 0; room <= top_of_world; room++)
|
|
||||||
for (door = 0; door < NUM_OF_DIRS; door++)
|
|
||||||
if (world[room].dir_option[door])
|
|
||||||
if (world[room].dir_option[door]->to_room != NOWHERE)
|
|
||||||
world[room].dir_option[door]->to_room =
|
|
||||||
real_room(world[room].dir_option[door]->to_room,
|
|
||||||
world[room].number);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* procedures for resetting, both play-time and boot-time *
|
* procedures for resetting, both play-time and boot-time *
|
||||||
*********************************************************************** */
|
*********************************************************************** */
|
||||||
@@ -464,32 +498,6 @@ char *fread_string(FILE * fl, char *error)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* returns the real number of the room with given virtual number */
|
|
||||||
int real_room(int virtual, int reference)
|
|
||||||
{
|
|
||||||
int bot, top, mid;
|
|
||||||
|
|
||||||
bot = 0;
|
|
||||||
top = top_of_world;
|
|
||||||
|
|
||||||
/* perform binary search on world-table */
|
|
||||||
for (;;) {
|
|
||||||
mid = (bot + top) / 2;
|
|
||||||
|
|
||||||
if ((world + mid)->number == virtual)
|
|
||||||
return (mid);
|
|
||||||
if (bot >= top) {
|
|
||||||
fprintf(stderr, "Room %d does not exist in database (referenced in room %d)\n", virtual, reference);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
if ((world + mid)->number > virtual)
|
|
||||||
top = mid - 1;
|
|
||||||
else
|
|
||||||
bot = mid + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* get_line reads the next non-blank line off of the input stream.
|
/* get_line reads the next non-blank line off of the input stream.
|
||||||
* The newline character is removed from the input. Lines which begin
|
* The newline character is removed from the input. Lines which begin
|
||||||
* with '*' are considered to be comments.
|
* with '*' are considered to be comments.
|
||||||
|
|||||||
Reference in New Issue
Block a user