Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 3c286fe6 authored by deuce's avatar deuce

More file resets...

parent 9c95665f
......@@ -10,12 +10,6 @@
#include "todo.h"
struct map_file {
int fd;
off_t len;
void *data;
};
struct map_file poison_map;
struct poison *poison;
......@@ -45,7 +39,7 @@ static size_t align(size_t val)
return(val);
}
static void map_file(char *name, struct map_file *map, size_t len)
void map_file(char *name, struct map_file *map, size_t len)
{
map->fd=open(name, O_RDWR);
if(map->fd == -1)
......@@ -56,7 +50,7 @@ static void map_file(char *name, struct map_file *map, size_t len)
CRASH;
}
static void unmap_file(struct map_file *map)
void unmap_file(struct map_file *map)
{
msync(map->data, map->len, MS_SYNC);
munmap(map->data, map->len);
......@@ -65,7 +59,7 @@ static void unmap_file(struct map_file *map)
void open_files(void)
{
map_file("poison.bin", &poison_map, MAX_POISON * sizeof(struct poison));
map_file("poison.dat", &poison_map, MAX_POISON * sizeof(struct poison));
poison=poison_map.data;
map_file("players.dat", &player_map, MAX_PLAYERS * sizeof(struct player));
players=player_map.data;
......@@ -78,138 +72,3 @@ void open_files(void)
map_file("king.dat", &king_map, MAX_OBJECTS * sizeof(struct king));
king=king_map.data;
}
void create_npc_file(void)
{
int fd;
struct player p;
int i;
fd=open("npcs.dat", O_WRONLY|O_TRUNC|O_CREAT, 0666);
memset(&p, 0, sizeof(p));
p.deleted=true;
for(i=0; i<MAX_PLAYERS; i++)
write(fd, &p, sizeof(p));
close(fd);
}
void create_player_file(void)
{
int fd;
struct player p;
int i;
fd=open("players.dat", O_WRONLY|O_TRUNC|O_CREAT, 0666);
memset(&p, 0, sizeof(p));
p.deleted=true;
for(i=0; i<MAX_PLAYERS; i++)
write(fd, &p, sizeof(p));
close(fd);
}
void create_poison_file(void)
{
int fd;
struct poison p;
int i;
fd=open("poison.bin", O_WRONLY|O_TRUNC|O_CREAT, 0666);
memset(&p, 0, sizeof(p));
for(i=0; i<21; i++)
write(fd, &p, sizeof(p));
close(fd);
map_file("poison.bin", &poison_map, MAX_POISON * sizeof(struct poison));
poison=poison_map.data;
strcpy(poison[0].name, "Snake Bite");
poison[0].strength=4;
poison[0].cost=1500;
strcpy(poison[1].name, "Xaminah Stir");
poison[1].strength=10;
poison[1].cost=11000;
strcpy(poison[2].name, "Zargothicia");
poison[2].strength=14;
poison[2].cost=25000;
strcpy(poison[3].name, "Diamond Sting");
poison[3].strength=17;
poison[3].cost=100000;
strcpy(poison[4].name, "Mynthia");
poison[4].strength=21;
poison[4].cost=300000;
strcpy(poison[5].name, "Exxodus");
poison[5].strength=41;
poison[5].cost=550000;
strcpy(poison[6].name, "Wolf Spit");
poison[6].strength=51;
poison[6].cost=850000;
strcpy(poison[7].name, "Joy of Death");
poison[7].strength=71;
poison[7].cost=1250000;
strcpy(poison[8].name, "Eusebius Cure");
poison[8].strength=81;
poison[8].cost=1500000;
strcpy(poison[9].name, "Yxaxxiantha");
poison[9].strength=85;
poison[9].cost=1900000;
strcpy(poison[10].name, "Polluted Lung");
poison[10].strength=90;
poison[10].cost=3000000;
strcpy(poison[11].name, "Postheria");
poison[11].strength=96;
poison[11].cost=6000000;
strcpy(poison[12].name, "Red Sledge");
poison[12].strength=100;
poison[12].cost=9000000;
strcpy(poison[13].name, "Mullamia");
poison[13].strength=110;
poison[13].cost=9100000;
strcpy(poison[14].name, "Cobra High");
poison[14].strength=115;
poison[14].cost=9200000;
strcpy(poison[15].name, "Stomach Claw");
poison[15].strength=120;
poison[15].cost=9300000;
strcpy(poison[16].name, "Fasanathievh");
poison[16].strength=125;
poison[16].cost=9400000;
strcpy(poison[17].name, "Urpathxiaveth");
poison[17].strength=130;
poison[17].cost=9500000;
strcpy(poison[18].name, "Dragon Flame");
poison[18].strength=135;
poison[18].cost=9600000;
strcpy(poison[19].name, "Usilamahs Bite");
poison[19].strength=140;
poison[19].cost=9700000;
strcpy(poison[20].name, "Devils Cure");
poison[20].strength=145;
poison[20].cost=9900000;
unmap_file(&poison_map);
}
void create_files(void)
{
create_poison_file();
}
......@@ -4,6 +4,7 @@
#include <stdbool.h>
#include <inttypes.h>
#include <time.h>
#include <unistd.h>
#define MAX_POISON 21
......@@ -144,8 +145,9 @@ enum onlinetype {
};
#define MAXNOD 5
#define MAX_ONLINERS 1000
struct onliner {
bool online;
char name[31]; // Player Alias
char realname[31]; // BBS Name
char node[4]; // Node as a three character string (zero padded)
......@@ -188,7 +190,7 @@ enum objtype {
Food,
Drink,
Weapon,
Abody
ABody
};
enum cures {
......@@ -232,6 +234,18 @@ struct object {
bool restr[MAXCLASSES];
};
struct armor {
char name[31];
long val;
long pow;
};
struct weapon {
char name[31];
long value;
long pow;
};
enum aitype {
AI_Computer,
AI_Human
......@@ -280,15 +294,60 @@ struct king {
bool shop_gigolos;
};
#define MAXMSPELLS 6
struct monster {
char name[31]; // Name of creature
long weapnr; // Weapon (from weapon data file) used
long armnr; // Armour (from data file) used
bool grabweap; // Can weapon be taken
bool grabarm; // Car armour be taken
char phrase[71]; // Intro phrase from monster
int magicres; // Magic resistance
int strength;
int defence;
bool wuser; // Weapon User
bool auser; // Armour User
long hps;
char weapon[41]; // Name of weapon
char armor[41]; // Name of armour
bool disease; // Infected by a disease?
long weappow; // Weapon Power
long armpow; // Armour power
int iq;
uint8_t evil; // Evilne4ss (0-100%)
uint8_t magiclevel; // The higher this is, the better the magic is
int mana; // Manna remaining
int maxmana;
bool spell[MAXMSPELLS]; // Monster Spells
long punch; // Temporary battle var(!)
bool poisoned; // Temporary battle var(!)
int target; // Temp. battle var
};
struct map_file {
int fd;
off_t len;
void *data;
};
extern struct map_file poison_map;
extern struct poison *poison;
extern struct onliner *onliners;
extern struct onliner *onliner;
extern struct player *players;
extern struct map_file player_map;
extern struct player *player;
extern struct player *players;
extern struct map_file npc_map;
extern struct player *npcs;
extern struct map_file onliner_map;
extern struct onliner *onliner;
extern struct onliner *onliners;
extern struct map_file object_map;
extern struct object *objects;
extern struct map_file king_map;
extern struct king *king;
void open_files(void);
void map_file(char *name, struct map_file *map, size_t len);
void unmap_file(struct map_file *map);
#endif
......@@ -150,6 +150,49 @@ void Add_Object(
write(fd, &obj, sizeof(obj));
}
void create_king_file(void)
{
int fd;
struct king king;
fd=open("king.dat", O_WRONLY|O_TRUNC|O_CREAT, 0666);
memset(&king, 0, sizeof(king));
strcpy(king.name, "Nobody");
king.ai=AI_Computer;
king.sexy=Male;
king.daysinpower=0;
king.tax=3;
king.taxalignment=AlignAll;
strcpy(king.moatid, "crocodile");
king.shop_weapon=true;
king.shop_armor=true;
king.shop_magic=true;
king.shop_alabat=true;
king.shop_plmarket=true;
king.shop_healing=true;
king.shop_drugs=true;
king.shop_steroids=true;
king.shop_orbs=true;
king.shop_evilmagic=true;
king.shop_bobs=true;
king.shop_gigolos=true;
write(fd, &king, sizeof(king));
close(fd);
}
void create_onliner_file(void)
{
int fd;
struct onliner ol;
int i;
fd=open("onliner.dat", O_WRONLY|O_TRUNC|O_CREAT, 0666);
memset(&ol, 0, sizeof(ol));
for(i=0; i<MAX_ONLINERS; i++)
write(fd, &ol, sizeof(ol));
close(fd);
}
void create_npc_file(void)
{
int fd;
......@@ -351,4 +394,6 @@ int main(int argc, char **argv)
create_poison_file();
create_player_file();
create_npc_file();
create_king_file();
create_onliner_file();
}
......@@ -3,36 +3,5 @@
#include <inttypes.h>
#define MAXMSPELLS 6
struct monster {
char name[31]; // Name of creature
long weapnr; // Weapon (from weapon data file) used
long armnr; // Armour (from data file) used
bool grabweap; // Can weapon be taken
bool grabarm; // Car armour be taken
char phrase[71]; // Intro phrase from monster
int magicres; // Magic resistance
int strength;
int defence;
bool wuser; // Weapon User
bool auser; // Armour User
long hps;
char weapon[41]; // Name of weapon
char armor[41]; // Name of armour
bool disease; // Infected by a disease?
long weappow; // Weapon Power
long armpow; // Armour power
int iq;
uint8_t evil; // Evilne4ss (0-100%)
uint8_t magiclevel; // The higher this is, the better the magic is
int mana; // Manna remaining
int maxmana;
bool spell[MAXMSPELLS]; // Monster Spells
long punch; // Temporary battle var(!)
bool poisoned; // Temporary battle var(!)
int target; // Temp. battle var
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment