mirror of
https://github.com/tbamud/tbamud.git
synced 2025-12-21 01:30:12 +01:00
Moved alias saving to Ascii pflies by default. Aliases in the old files will still be read (once per char)
This commit is contained in:
parent
40cc5f767c
commit
c6ada5a4d5
4 changed files with 89 additions and 11 deletions
|
|
@ -29,7 +29,7 @@ OBJFILES = act.comm.o act.informative.o act.item.o act.movement.o \
|
|||
fight.o genmob.o genobj.o genolc.o genshp.o genwld.o genzon.o graph.o \
|
||||
handler.o house.o improved-edit.o interpreter.o limits.o magic.o mail.o \
|
||||
medit.o mobact.o modify.o oasis.o oasis_copy.o oasis_delete.o \
|
||||
oasis_list.o objsave.o oedit.o olc.o random.o redit.o sedit.o \
|
||||
oasis_list.o objsave.o oedit.o random.o redit.o sedit.o \
|
||||
shop.o spec_assign.o spec_procs.o spell_parser.o spells.o tedit.o \
|
||||
utils.o weather.o zedit.o bsd-snprintf.o \
|
||||
dg_comm.o dg_db_scripts.o dg_event.o dg_handler.o dg_mobcmd.o \
|
||||
|
|
@ -43,7 +43,7 @@ CXREF_FILES = act.comm.c act.informative.c act.item.c act.movement.c \
|
|||
fight.c genmob.c genobj.c genolc.c genshp.c genwld.c genzon.c graph.c \
|
||||
handler.c house.c improved-edit.c interpreter.c limits.c magic.c mail.c \
|
||||
medit.c mobact.c modify.c oasis.c oasis_copy.o oasis_delete.c \
|
||||
oasis_list.o objsave.c oedit.c olc.c random.c redit.c sedit.c \
|
||||
oasis_list.o objsave.c oedit.c random.c redit.c sedit.c \
|
||||
shop.c spec_assign.c spec_procs.c spell_parser.c spells.c tedit.c \
|
||||
utils.c weather.c zedit.c hedit.c bsd-snprintf.c players.c
|
||||
|
||||
|
|
|
|||
64
src/alias.c
64
src/alias.c
|
|
@ -138,3 +138,67 @@ void delete_aliases(const char *charname)
|
|||
*/
|
||||
}
|
||||
|
||||
|
||||
// until further notice, the alias->pfiles save and load functions will function
|
||||
// along side the old seperate alias file load, for compatibility.
|
||||
void write_aliases_ascii(FILE *file, struct char_data *ch)
|
||||
{
|
||||
struct alias_data *temp;
|
||||
int count = 0;
|
||||
|
||||
if (GET_ALIASES(ch) == NULL)
|
||||
return;
|
||||
|
||||
for (temp = GET_ALIASES(ch); temp; temp = temp->next)
|
||||
count++;
|
||||
|
||||
fprintf(file, "Alis: %d\n", count);
|
||||
// the +1 thing below is due to alias replacements having
|
||||
// a space prepended in memory. The reason for this escapes me.
|
||||
// Welcor 27/12/06
|
||||
for (temp = GET_ALIASES(ch); temp; temp = temp->next) {
|
||||
|
||||
fprintf(file, "%s\n" /* Alias */
|
||||
"%s\n" /* Replacement */
|
||||
"%d\n", /* Type */
|
||||
temp->alias,
|
||||
temp->replacement+1,
|
||||
temp->type);
|
||||
}
|
||||
}
|
||||
|
||||
void read_aliases_ascii(FILE *file, struct char_data *ch, int count)
|
||||
{
|
||||
int i;
|
||||
struct alias_data *temp;
|
||||
char abuf[MAX_INPUT_LENGTH], rbuf[MAX_INPUT_LENGTH+1], tbuf[MAX_INPUT_LENGTH];
|
||||
|
||||
if (count == 0) {
|
||||
GET_ALIASES(ch) = NULL;
|
||||
return; // no aliases in the list
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
/* Read the aliased command. */
|
||||
get_line(file, abuf);
|
||||
|
||||
/* Read the replacement. */
|
||||
get_line(file, tbuf);
|
||||
strcpy(rbuf, " ");
|
||||
strcat(rbuf, tbuf); // strcat: OK
|
||||
|
||||
/* read the type */
|
||||
get_line(file, tbuf);
|
||||
|
||||
if (abuf && *abuf && tbuf && *tbuf && rbuf && *rbuf)
|
||||
{
|
||||
CREATE(temp, struct alias_data, 1);
|
||||
temp->alias = strdup(abuf);
|
||||
temp->replacement = strdup(rbuf);
|
||||
temp->type = atoi(tbuf);
|
||||
temp->next = GET_ALIASES(ch);
|
||||
GET_ALIASES(ch) = temp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -743,8 +743,8 @@ ACMD(do_alias)
|
|||
a->type = ALIAS_SIMPLE;
|
||||
a->next = GET_ALIASES(ch);
|
||||
GET_ALIASES(ch) = a;
|
||||
write_aliases(ch);
|
||||
send_to_char(ch, "Alias saved.\r\n");
|
||||
// save_char(ch);
|
||||
send_to_char(ch, "Alias ready.\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1317,7 +1317,16 @@ int enter_player_game (struct descriptor_data *d)
|
|||
room_vnum load_room;
|
||||
|
||||
reset_char(d->character);
|
||||
/*
|
||||
* See if there might be some aliases in the old alias file.
|
||||
* Only do this if there were no aliases in the pfile.
|
||||
*/
|
||||
if (GET_ALIASES(d->character) == NULL)
|
||||
{
|
||||
read_aliases(d->character);
|
||||
// delete the old file - player will be saved in a second.
|
||||
delete_aliases(GET_NAME(d->character));
|
||||
}
|
||||
|
||||
if (PLR_FLAGGED(d->character, PLR_INVSTART))
|
||||
GET_INVIS_LEV(d->character) = GET_LEVEL(d->character);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
#include "pfdefaults.h"
|
||||
#include "dg_scripts.h"
|
||||
#include "comm.h"
|
||||
#include "genmob.h"
|
||||
|
||||
#define LOAD_HIT 0
|
||||
#define LOAD_MANA 1
|
||||
|
|
@ -36,6 +35,8 @@ void load_HMVS(struct char_data *ch, const char *line, int mode);
|
|||
/* external fuctions */
|
||||
bitvector_t asciiflag_conv(char *flag);
|
||||
void save_char_vars(struct char_data *ch);
|
||||
void write_aliases_ascii(FILE *file, struct char_data *ch);
|
||||
void read_aliases_ascii(FILE *file, struct char_data *ch, int count);
|
||||
|
||||
/* 'global' vars */
|
||||
struct player_index_element *player_table = NULL; /* index to plr file */
|
||||
|
|
@ -290,6 +291,7 @@ int load_char(const char *name, struct char_data *ch)
|
|||
GET_OLC_ZONE(ch) = PFDEF_OLC;
|
||||
GET_HOST(ch) = NULL;
|
||||
GET_PAGE_LENGTH(ch) = PFDEF_PAGELENGTH;
|
||||
GET_ALIASES(ch) = NULL;
|
||||
|
||||
while (get_line(fl, line)) {
|
||||
tag_argument(line, tag);
|
||||
|
|
@ -301,6 +303,7 @@ int load_char(const char *name, struct char_data *ch)
|
|||
else if (!strcmp(tag, "Aff ")) AFF_FLAGS(ch) = asciiflag_conv(line);
|
||||
else if (!strcmp(tag, "Affs")) load_affects(fl, ch);
|
||||
else if (!strcmp(tag, "Alin")) GET_ALIGNMENT(ch) = atoi(line);
|
||||
else if (!strcmp(tag, "Alis")) read_aliases_ascii(fl, ch, atoi(line));
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
|
|
@ -351,7 +354,7 @@ int load_char(const char *name, struct char_data *ch)
|
|||
|
||||
case 'L':
|
||||
if (!strcmp(tag, "Last")) ch->player.time.logon = atol(line);
|
||||
else if (!strcmp(tag, "Lern")) GET_PRACTICES(ch) = atoi(line);
|
||||
else if (!strcmp(tag, "Lern")) GET_PRACTICES(ch) = atoi(line);
|
||||
else if (!strcmp(tag, "Levl")) GET_LEVEL(ch) = atoi(line);
|
||||
break;
|
||||
|
||||
|
|
@ -365,11 +368,11 @@ int load_char(const char *name, struct char_data *ch)
|
|||
break;
|
||||
|
||||
case 'O':
|
||||
if (!strcmp(tag, "Olc ")) GET_OLC_ZONE(ch) = atoi(line);
|
||||
break;
|
||||
if (!strcmp(tag, "Olc ")) GET_OLC_ZONE(ch) = atoi(line);
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
if (!strcmp(tag, "Page")) GET_PAGE_LENGTH(ch) = atoi(line);
|
||||
if (!strcmp(tag, "Page")) GET_PAGE_LENGTH(ch) = atoi(line);
|
||||
else if (!strcmp(tag, "Pass")) strcpy(GET_PASSWD(ch), line);
|
||||
else if (!strcmp(tag, "Plyd")) ch->player.time.played = atoi(line);
|
||||
#if ASCII_SAVE_POOFS
|
||||
|
|
@ -640,6 +643,8 @@ void save_char(struct char_data * ch)
|
|||
fprintf(fl, "0 0 0 0 0\n");
|
||||
}
|
||||
|
||||
if (GET_ALIASES(ch)) write_aliases_ascii(fl, ch);
|
||||
|
||||
fclose(fl);
|
||||
|
||||
/* more char_to_store code to restore affects */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue