Skip to content

Commit

Permalink
Added MASSIVE changes to the wilderness:
Browse files Browse the repository at this point in the history
 - FOV
 - Regions
 - Database support
 - Tracking
 - Map enhancements



git-svn-id: svn+ssh://50.28.74.132/home/luminari/svn/luminari/myproject/trunk@1349 dda7f814-ccd3-4591-a6d7-1bd23e5e64af
  • Loading branch information
luminari committed Sep 26, 2013
1 parent 441db13 commit b577d79
Show file tree
Hide file tree
Showing 28 changed files with 634 additions and 733 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ BINDIR = ../bin

CFLAGS = -g -O2 $(MYFLAGS) $(PROFILE)

LIBS = -lcrypt -lgd -lm
LIBS = -lcrypt -lgd -lm -lmysqlclient

SRCFILES := $(wildcard *.c)
SRCFILES := $(wildcard *.c) $(wildcard rtree/*.c)
OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))

default: all
Expand Down
1 change: 1 addition & 0 deletions act.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ ACMD(do_weather);
ACMD(do_where);
ACMD(do_who);
ACMD(do_whois);
ACMD(do_track);

/*****************************************************************************
* Begin Functions and defines for act.item.c
Expand Down
120 changes: 120 additions & 0 deletions act.informative.c
Original file line number Diff line number Diff line change
Expand Up @@ -3641,3 +3641,123 @@ ACMD(do_exits) {
if (!len)
send_to_char(ch, " None.\r\n");
}

ACMD(do_track) {
struct event * pEvent = NULL;
struct mud_event_data *pMudEvent = NULL;
char arg[MAX_INPUT_LENGTH];

char creator_race[20]; /* The RACE of what created the tracks. */
char creator_name[20]; /* The NAME of what created the tracks. */
int track_age = 0; /* The AGE of this set of tracks. */
char track_dir[6]; /* The direction the track leads. */

const char* track_age_names[7] = { "extremely old",
"very old",
"old",
"fairly recent",
"recent",
"fairly fresh",
"fresh" };

/* The character must have the track skill. */
if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_TRACK)) {
send_to_char(ch, "You have no idea how.\r\n");
return;
}

one_argument(argument, arg);

send_to_char(ch, "You search the area for tracks...\r\n");

/* Check if there are any tracks to see. */
/* Need to iterate over all of this room's events, picking out the tracking ones.
* What a PAIN, this really should be easier. */

// for( pMudEvent = room_has_mud_event(world[IN_ROOM(ch)], eTRACKS);
// pMudEvent != NULL;
// pMudEvent = room_has_mud_event(world[IN_ROOM(ch)], eTRACKS)) {

if((!room_has_mud_event(&world[IN_ROOM(ch)], eTRACKS)) ||
((world[IN_ROOM(ch)].events == NULL) || (world[IN_ROOM(ch)].events->iSize == 0))) {
send_to_char(ch, "You can't find any tracks.\r\n");
return;
}

simple_list(NULL);

while ((pEvent = (struct event *) simple_list(world[IN_ROOM(ch)].events)) != NULL) {
if (!pEvent->isMudEvent)
continue;

pMudEvent = (struct mud_event_data *) pEvent->event_obj;

if (pMudEvent->iId == eTRACKS) {

/* Get the track information from the sVariables. */
if ( pMudEvent->sVariables )
sscanf(pMudEvent->sVariables, "%d \"%19[^\"]\" \"%19[^\"]\" %s", &track_age, creator_race, creator_name, track_dir);

/* Skill check. */

// send_to_char(ch, "%s\r\n", pMudEvent->sVariables);
// send_to_char(ch, "%d %s %s %s\r\n", track_age, creator_race, creator_name, track_dir);

if (*arg && isname(arg, creator_name) ) {
/* Found our victim's tracks. */
send_to_char(ch, " You find %s tracks of %s leading %s.\r\n", track_age_names[track_age],
creator_name,
track_dir);

} else if ((!*arg) || (*arg && isname(arg, creator_race))) {
send_to_char(ch, " You find %s tracks of %s %s leading %s.\r\n", track_age_names[track_age],
a_or_an(creator_race),
creator_race,
track_dir);
}
}
}
}

/* Event function for tracks, causing decay and eventual removal. */
EVENTFUNC(event_tracks) {
struct mud_event_data *pMudEvent = NULL;
struct room_data *room = NULL;
room_rnum rnum = NOWHERE;
char buf[128];

char creator_race[20]; /* The RACE of what created the tracks. */
char creator_name[20]; /* The NAME of what created the tracks. */
int track_age = 0; /* The AGE of this set of tracks. */
char track_dir[6]; /* The direction the track leads. */


/* Unpack the mud data. */
pMudEvent = (struct mud_event_data *) event_obj;

if (!pMudEvent)
return 0;

if (!pMudEvent->iId)
return 0;

room = (struct room_data *) pMudEvent->pStruct;
rnum = real_room(room->number);

/* Get the track information from the sVariables. */
if ( pMudEvent->sVariables )
sscanf(pMudEvent->sVariables, "%d \"%19[^\"]\" \"%19[^\"]\" %s", &track_age, creator_race, creator_name, track_dir);

if ( track_age == 0 ) /* Time for this track to disappear. */
return 0;
else
track_age--; /* Age the track. */

/* Now change the age in the sVariables, and resubmit the tracks. */
// free(pMudEvent->sVariables);
sprintf(buf, "%d \"%s\" \"%s\" %s", track_age, creator_race, creator_name, track_dir);
pMudEvent->sVariables = strdup(buf);

return 60 RL_SEC; /* Decay tracks every 60 seconds, subject to change :) */
}

11 changes: 10 additions & 1 deletion act.movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,9 @@ int do_simple_move(struct char_data *ch, int dir, int need_specials_check) {
struct char_data *tch = NULL, *next_tch = NULL;
// for mount code
int same_room = 0, riding = 0, ridden_by = 0;
/* extra buffer */
/* extra buffers */
char buf2[MAX_STRING_LENGTH] = {'\0'};
char buf3[MAX_STRING_LENGTH] = {'\0'};
/* singlefile variables */
struct char_data *other;
struct char_data **prev;
Expand Down Expand Up @@ -1020,6 +1021,14 @@ int do_simple_move(struct char_data *ch, int dir, int need_specials_check) {
/* end leave-room message code */
/*****/

/* Leave tracks, if not riding. */
if (!riding) {
sprintf(buf3, "%d \"%s\" \"%s\" %s", 6,
(IS_NPC(ch) ? npc_race_types[GET_NPC_RACE(ch)] : pc_race_types[GET_RACE(ch)]),
GET_NAME(ch),
dirs[dir]);
NEW_EVENT(eTRACKS, &world[IN_ROOM(ch)],buf3, 60 RL_SEC);
}
/* the actual technical moving of the char */
char_from_room(ch);

Expand Down
44 changes: 37 additions & 7 deletions act.wizard.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "hlquest.h"
#include "mudlim.h"
#include "spec_abilities.h"

#include "wilderness.h"

/* local utility functions with file scope */
static int perform_set(struct char_data *ch, struct char_data *vict, int mode, char *val_arg);
Expand Down Expand Up @@ -259,9 +259,22 @@ ACMD(do_goto) {
char arg[MAX_INPUT_LENGTH], arg2[MAX_INPUT_LENGTH];
room_rnum location;

if ((location = find_target_room(ch, argument)) == NOWHERE)
return;

two_arguments(argument, arg, arg2);

if(!*arg2) {
if ((location = find_target_room(ch, argument)) == NOWHERE)
return;
} else {
/* Have two args, that means coordinates (potentially) */
if ((location = find_room_by_coordinates(atoi(arg), atoi(arg2))) == NOWHERE) {
if((location = find_available_wilderness_room()) == NOWHERE) {
return;
} else {
/* Must set the coords, etc in the going_to room. */
assign_wilderness_room(location, atoi(arg), atoi(arg2));
}
}
}

if (ZONE_FLAGGED(GET_ROOM_ZONE(location), ZONE_NOIMMORT) && (GET_LEVEL(ch) >= LVL_IMMORT) && (GET_LEVEL(ch) < LVL_GRSTAFF)) {
send_to_char(ch, "Sorry, that zone is off-limits for immortals!");
Expand All @@ -275,6 +288,7 @@ ACMD(do_goto) {
char_from_room(ch);

if(ZONE_FLAGGED(GET_ROOM_ZONE(location), ZONE_WILDERNESS)) {
// char_to_coords(ch, world[location].coords[0], world[location].coords[1], 0);
X_LOC(ch) = world[location].coords[0];
Y_LOC(ch) = world[location].coords[1];
}
Expand Down Expand Up @@ -2649,13 +2663,17 @@ ACMD(do_wizutil) {
code 3 times ... -je, 4/6/93 FIXME: overflow possible */
static size_t print_zone_to_buf(char *bufptr, size_t left, zone_rnum zone, int listall) {
size_t tmp;
double avglvl = 0;
int mcount = 0;
mob_rnum mrnum;

if (listall) {
int i, j, k, l, m, n, o;
char buf[MAX_STRING_LENGTH];

sprintbitarray(zone_table[zone].zone_flags, zone_bits, ZN_ARRAY_MAX, buf);


tmp = snprintf(bufptr, left,
"%3d %-30.30s%s By: %-10.10s%s Age: %3d; Reset: %3d (%s);Show Weather %d; Range: %5d-%5d\r\n",
zone_table[zone].number, zone_table[zone].name, KNRM, zone_table[zone].builders, KNRM,
Expand Down Expand Up @@ -2706,10 +2724,19 @@ static size_t print_zone_to_buf(char *bufptr, size_t left, zone_rnum zone, int l
return tmp;
}

for(mrnum = 0; mrnum <= top_of_mobt; mrnum++) {
if(mob_index[mrnum].vnum >= zone_table[zone].bot && mob_index[mrnum].vnum <= zone_table[zone].top) {
avglvl += mob_proto[mrnum].player.level;
mcount++;
}
}

avglvl = avglvl/(double)mcount;

return snprintf(bufptr, left,
"%3d %-*s%s By: %-10.10s%s Range: %5d-%5d\r\n", zone_table[zone].number,
"%3d %-*s%s By: %-10.10s%s Range: %5d-%5d AvgLvl: ,%2.3f\r\n", zone_table[zone].number,
count_color_chars(zone_table[zone].name) + 30, zone_table[zone].name, KNRM,
zone_table[zone].builders, KNRM, zone_table[zone].bot, zone_table[zone].top);
zone_table[zone].builders, KNRM, zone_table[zone].bot, zone_table[zone].top, avglvl);
}

ACMD(do_show) {
Expand Down Expand Up @@ -5691,13 +5718,16 @@ ACMD(do_singlefile) {
#include "wilderness.h"
#include "kdtree.h"

#include "mysql.h"
#include "rtree/rTreeIndex.h"

/* Test command to display a map, radius 4, generated using noise. */
ACMD(do_genmap) {

void *set;
double pos[2], point[2];
room_rnum *room;

int j = 0;

point[0] = 0;
point[1] = 0;
Expand Down
10 changes: 9 additions & 1 deletion asciimap.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ static struct map_info_type map_info[] ={
{ SECT_D_ROAD_EW, "\tc[\ty-\tc]\tn"},
{ SECT_D_ROAD_INT, "\tc[\ty+\tc]\tn"},
{ SECT_CAVE, "\tc[\tD\t=C\tc]\tn"},

{ SECT_JUNGLE, "\tg&\tn"},
{ SECT_TUNDRA, "\tW.\tn"},
{ SECT_TAIGA, "\tgA\tn"},
{ SECT_BEACH, "\ty:\tn"},

{ -1, ""}, /* RESERVED, NUM_ROOM_SECTORS */
{ SECT_EMPTY, " "}, /* NUM_ROOM_SECTORS + 1 */
{ SECT_STRANGE, "\tc[\tR?\tc]\tn"},
Expand Down Expand Up @@ -174,6 +178,10 @@ static struct map_info_type world_map_info[] ={
{ SECT_D_ROAD_EW, "\ty-\tn"},
{ SECT_D_ROAD_INT, "\ty+\tn"},
{ SECT_CAVE, "\tD\t=C\tn"},
{ SECT_JUNGLE, "\tg&\tn"},
{ SECT_TUNDRA, "\tW.\tn"},
{ SECT_TAIGA, "\tgA\tn"},
{ SECT_BEACH, "\ty:\tn"},

{ -1, ""}, /* RESERVED, NUM_ROOM_SECTORS */
{ SECT_EMPTY, " "},
Expand Down
45 changes: 41 additions & 4 deletions db.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "spec_abilities.h"
#include "perlin.h"
#include "wilderness.h"
#include "mysql.h"

#include <sys/stat.h>
/* declarations of most of the 'global' variables */
Expand All @@ -71,6 +72,9 @@ obj_rnum top_of_objt = 0; /* top of object index table */
struct zone_data *zone_table = NULL; /* zone table */
zone_rnum top_of_zone_table = 0; /* top element of zone tab */

struct region_data *region_table = NULL; /* Region table */
region_rnum top_of_region_table = 0; /* top element of region tab */

/* begin previously located in players.c */
struct player_index_element *player_table = NULL; /* index to plr file */
int top_of_p_table = 0; /* ref to top of table */
Expand Down Expand Up @@ -435,6 +439,9 @@ ACMD(do_reboot) {
void boot_world(void) {
int x = 0;

/* Initialize the db connection. */
connect_to_mysql();

log("Loading zone table.");
index_boot(DB_BOOT_ZON);

Expand All @@ -444,6 +451,10 @@ void boot_world(void) {
log("Loading rooms.");
index_boot(DB_BOOT_WLD);

log("Loading regions. (MySQL)");
load_regions();


log("Renumbering rooms.");
renum_world();

Expand Down Expand Up @@ -485,12 +496,12 @@ void boot_world(void) {

log("Indexing wilderness rooms.");
initialize_wilderness_lists();

log("Writing wilderness map image.");
save_map_to_file("luminari_wilderness.png", 1024, 1024);
save_noise_to_file(NOISE_MATERIAL_PLANE_ELEV, "luminari_wild_noise_elev.png", 1024, 1024);
// save_noise_to_file(NOISE_MATERIAL_PLANE_MOISTURE, "luminari_wild_noise_mois.png", 1024, 1024);
// save_map_to_file("luminari_wilderness.png", WILD_X_SIZE, WILD_Y_SIZE);

//save_noise_to_file(NOISE_MATERIAL_PLANE_ELEV, "luminari_wild_noise_elev_zoom.png", WILD_X_SIZE, WILD_Y_SIZE, 0);
//save_noise_to_file(NOISE_MATERIAL_PLANE_ELEV, "luminari_wild_noise_elev_zoom.png", WILD_X_SIZE, WILD_Y_SIZE, 1);
}

static void free_extra_descriptions(struct extra_descr_data *edesc) {
Expand Down Expand Up @@ -4333,6 +4344,32 @@ zone_rnum real_zone(zone_vnum vnum) {
return (NOWHERE);
}

/* returns the real number of the region with given virtual number */
region_rnum real_region(region_vnum vnum) {
region_rnum bot, top, mid;

bot = 0;
top = top_of_region_table;

log(" real_region %d %d", bot, top_of_region_table);
log(" %d %d vnum: %d", region_table[top].vnum, region_table[bot].vnum, vnum);
if (region_table[bot].vnum > vnum || region_table[top].vnum < vnum)
return (NOWHERE);

/* perform binary search on zone-table */
while (bot <= top) {
mid = (bot + top) / 2;
log(" mid : %d vnum: %d", mid, (region_table + mid)->vnum);
if ((region_table + mid)->vnum == vnum)
return (mid);
if ((region_table + mid)->vnum > vnum)
top = mid - 1;
else
bot = mid + 1;
}
return (NOWHERE);
}

/* Extend later to include more checks and add checks for unknown bitvectors. */
static int check_object(struct obj_data *obj) {
char objname[MAX_INPUT_LENGTH + 32];
Expand Down
Loading

0 comments on commit b577d79

Please sign in to comment.