Hi guys and girls, I'd like to see circles character related structures being cleaned up. There are a few things that are confusing, things that have different meaning for PC's or NPC's, like name, short_description, long_description, and description. I don't know exactly anymore but I think name is the PC's name and the NPC's name list, short_description is the NPC's name and nothing for the PC, long_description is the NPC's description and nothing for the PC, and description is the PC's description and the NPC's description for the default position. I probebly have some things wrong but the point is this can be made less confusing and complex. There are also a few things that take unneccesary memory, like the mob_specials which are also in the PC's data structures. Pointers to these structures could be used that are only alocated for NPC. There are a few things that need to be saved seperate into the player file. (sex, level, weight, height, etc.) These could be put in a structure and saved that way. Also not all data has a macro, and not always the macro is used in the code. (very anoying if you want to change the structures) So these things are the things I'd like to see changed in the circle code. Instead of telling how I'd like to see the structures changed I've changed the relevant parts of structs.h and utils.h and added them here. It makes this mail quiet a bit longer but it will be a lot easyer to read than my english (for coders anyway). Most changes are just name changes, some things had the wrong name or were double. (like the name and description strings I mentioned above) (most name changes are just changes to my taste, like struct char_data to struct character etc.) Another change is the proto type table. It exists of 3 elements now and makes the mob_index table obsolete. A bigger part of the NPC data is now only to be find in the proto table (was index table) this saves memory. The macro name have the CHAR_ prefix for NPC and PC data, NPC_ for NPC-only data and PC_ for PC-only data. The GET_ prefix is only used when the macro can't be used for a l-value. I hope you all like the structures suggested by me and that someone is willing to put them into circle (I have some tips to do it fast but it will still be a lot of work). I apologize for the long mail (please be careful not to include it all in a reply). Jaco. #################################################################### /* * char-related structures (structs.h) */ /* strings for both PC's and NPC's */ struct char_strings { char *name_list; char *short_description; char *long_description; }; /* strings for PC's */ struct player_strings { char *title; char *poofin; char *poofout; }; /* strings for NPC's */ struct npc_strings { char *default_line; }; /* data for both PC's and NPC's, is saved in player file */ struct saved_char { byte sex; byte class; byte level; ubyte weight; ubyte height; short alignment; char armor_class; byte hitroll; byte damroll; int gold; int bank_gold; }; /* data for PC's, is saved in player file */ struct saved_player { byte hometown; byte clan; byte guild; }; /* abilities for PC's and NPC's, is saved in player file */ struct saved_abilities { byte str; byte str_add; byte intel; byte wis; byte dex; byte con; byte cha; }; /* points for PC's and NPC's, is saved in player file */ struct saved_points { short hit; short max_hit; short mana; short max_mana; short move; short max_move; int experience; }; /* specials for PC's and NPC's, is saved in player file */ struct saved_char_specials { /* idnum this is probably a PC only thing, I'm not sure */ long idnum; struct char_affections affected_by; }; /* specials for PC's, is saved in player file */ struct saved_player_specials { room_num load_room; byte invis_level; byte bad_pws; byte wimp_level; byte spells_to_learn; char freeze_level; byte conditions[3]; byte skills[MAX_SKILLS+1]; bool talks[MAX_TONGUE]; struct time_data time; struct preferances pref; struct player_flags flag; }; /* An affect structure, is saved in player file */ struct affected_type { /* no more next pointer, changed from linked list to * (growing and shrinking) table (saves bytes, smaller pfile) */ short type; short duration; ubyte location; byte modifier; struct char_affections bitvector; }; struct affections_list { /* head of affections table and number of elements */ ubyte number_of_affections; struct affected_type *affect; }; /* Structure used for chars following other chars */ struct follow_type { struct character *follower; struct follow_type *next; }; /* all PC only data */ struct pc_only { int file_position; room_num was_in_room; /* for linkdead */ void *last_olc_targ; int last_olc_mode; struct alias *aliases; struct character *last_tell; struct player_strings string; struct saved_player data; struct saved_player_specials specials; struct saved_abilities base_abilities; }; /* data that doesn't need to be copied for new mobiles */ struct npc_only_shared { int virtual_number; short index_number; int total_in_game; byte default_pos; byte attack_type; byte damnodice; byte damsizedice; SPEC_PROCIAL(*func); }; /* all NPC only data */ struct npc_only { struct npc_strings string; struct character *fighting[3]; struct mobflags flag; byte last_direction; memory_rec *memory; struct npc_only_shared *shared; }; /* ================== Structure for player/non-player ===================== */ struct character { room_num in_room; byte position; byte lost_time; byte carry_items; byte num_affections; int carry_weight; int idle_timer; short apply[4]; short apply_saving_throw[5]; struct saved_char data; struct saved_char_specials specials; struct saved_points points; struct char_strings string; struct affections_list affections; struct saved_abilities abilities; struct pc_only *pc; struct npc_only *npc; struct obj_data *equipment[NUM_WEARS]; struct obj_data *carrying; struct descriptor_data *desc; struct character *next_in_room; struct character *next; struct character *next_fighting; struct character *fighting; struct character *hunting; struct follow_type *followers; struct character *master; struct mob_prog_act_list *mpact; int mpactnum; }; /* File Structure for Player. BEWARE: Changing it will ruin the playerfile */ struct char_file_u { /* strings */ char name[MAX_NAME_LENGTH+1]; char password[MAX_PWD_LENGTH+1]; char description[EXDSCR_LENGTH]; char title[MAX_TITLE_LENGTH+1]; char host[HOST_LENGTH+1]; char poofin[MAX_TITLE_LENGTH+1]; char poofout[MAX_TITLE_LENGTH+1]; /* structures */ struct saved_char char_data; struct saved_player player_data; struct saved_char_specials char_specials; struct saved_player_specials player_specials; struct saved_abilities abilities; struct saved_points points; struct player_flags flag; struct affected_type affect[MAX_AFFECT]; }; /* npc prototype table element */ struct npc { /* replaces mob_proto and mob_index */ struct character character; struct npc_only npc_only; struct npc_only_shared npc_only_shared; }; #################################################################### /* character related macros in utils.h */ /* character strings */ #define CHAR_NAME_LIST(ch) (ch)->string.name_list #define CHAR_NAME(ch) (ch)->string.short_description #define CHAR_DESCRIPTION(ch) (ch)->string.long_description /* pc only strings strings */ #define PC_TITLE(ch) (ch)->pc->string.title #define PC_POOFIN(ch) (ch)->pc->string.poofin #define PC_POOFOUT(ch) (ch)->pc->string.poofout /* npc only strings strings */ #define NPC_DEFAULT_LINE(ch) (ch)->npc->string.default_line /* character data */ #define CHAR_SEX(ch) (ch)->data.sex #define CHAR_CLASS(ch) (ch)->data.class #define CHAR_LEVEL(ch) (ch)->data.level #define CHAR_HEIGHT(ch) (ch)->data.height #define CHAR_WEIGHT(ch) (ch)->data.weight #define CHAR_ALIGNMENT(ch) (ch)->data.alignment #define CHAR_AC(ch) (ch)->data.armor_class #define CHAR_HITROLL(ch) (ch)->data.hitroll #define CHAR_DAMROLL(ch) (ch)->data.damroll #define CHAR_GOLD(ch) (ch)->data.gold #define CHAR_BANK_GOLD(ch) (ch)->data.bank_gold /* pc only data */ #define PC_HOMETOWN(ch) (ch)->pc->data.hometown #define PC_CLAN(ch) (ch)->pc->data.clan #define PC_GUILD(ch) (ch)->pc->data.guild /* character abilities */ #define CHAR_STR(ch) (ch)->abilities.str #define CHAR_ADD(ch) (ch)->abilities.str_add #define CHAR_DEX(ch) (ch)->abilities.dex #define CHAR_INT(ch) (ch)->abilities.intel #define CHAR_WIS(ch) (ch)->abilities.wis #define CHAR_CON(ch) (ch)->abilities.con #define CHAR_CHA(ch) (ch)->abilities.cha /* character points */ #define CHAR_HIT(ch) (ch)->points.hit #define CHAR_MAX_HIT(ch) (ch)->points.max_hit #define CHAR_MANA(ch) (ch)->points.mana #define CHAR_MAX_MANA(ch) (ch)->points.max_mana #define CHAR_MOVE(ch) (ch)->points.move #define CHAR_MAX_MOVE(ch) (ch)->points.max_move #define CHAR_EXP(ch) (ch)->points.experience /* character specials */ #define CHAR_IDNUM(ch) (ch)->specials.idnum #define AFF_FLAGS(ch) (ch)->specials.affected_by /* pc only specials */ #define PC_LOADROOM(ch) (ch)->pc->specials.load_room #define PC_INVIS_LEV(ch) (ch)->pc->specials.invis_level #define PC_BAD_PWS(ch) (ch)->pc->specials.bad_pws #define PC_WIMP_LEV(ch) (ch)->pc->specials.wimp_level #define PC_PRACTICES(ch) (ch)->pc->specials.spells_to_learn #define PC_FREEZE_LEV(ch) (ch)->pc->specials.freeze_level #define CHAR_COND(ch, i) (ch)->pc->specials.conditions[(i)] #define PC_SKILL(ch, i) (ch)->pc->specials.skills[(i)] #define PC_TALK(ch, i) (ch)->pc->specials.talks[(i)] #define PC_BORN(ch) (ch)->pc->specials.time.birth #define PC_PLAYED(ch) (ch)->pc->specials.time.played #define PC_LOGON(ch) (ch)->pc->specials.time.logon #define PRF_FLAGS(ch) (ch)->pc->specials.pref #define PLR_FLAGS(ch) (ch)->pc->specials.flag /* character affection list */ #define CHAR_AF_NUM(ch) (ch)->affections.number_of_affections #define CHAR_AFFECTIONS(ch) (ch)->affections.affect #define CHAR_AFFECTION(ch, i) CHAR_AFFECTIONS(ch)[(i)] #define CHAR_AF_TYPE(ch, i) CHAR_AFFECTION((ch),(i)).type #define CHAR_AF_DURATION(ch, i) CHAR_AFFECTION((ch),(i)).duration #define CHAR_AF_LOCATION(ch, i) CHAR_AFFECTION((ch),(i)).location #define CHAR_AF_MODIFIER(ch, i) CHAR_AFFECTION((ch),(i)).modifier #define CHAR_AF_BITVECTOR(ch, i) CHAR_AFFECTION((ch),(i)).bitvector /* pc base abilities */ #define PC_BASE_ABILITIES(ch) (ch)->pc->base_abilities #define PC_BASE_STR(ch) (ch)->pc->base_abilities.str #define PC_BASE_ADD(ch) (ch)->pc->base_abilities.str_add #define PC_BASE_DEX(ch) (ch)->pc->base_abilities.dex #define PC_BASE_INT(ch) (ch)->pc->base_abilities.intel #define PC_BASE_WIS(ch) (ch)->pc->base_abilities.wis #define PC_BASE_CON(ch) (ch)->pc->base_abilities.con #define PC_BASE_CHA(ch) (ch)->pc->base_abilities.cha /* other pc only data */ #define PC_FILE_POSITION(ch) (ch)->pc->file_position #define PC_WAS_IN(ch) (ch)->pc->was_in_room #define PC_ALIASES(ch) (ch)->pc->aliases #define PC_LAST_TELL(ch) (ch)->pc->last_tell /* shared npc only data */ #define NPC_VNUM(ch) (ch)->npc->shared->virtual_number #define NPC_INDEX(ch) (ch)->npc->shared->index_number #define NPC_TOTAL(ch) (ch)->npc->shared->total_in_game #define NPC_DEFAULT_POS(ch) (ch)->npc->shared->default_pos #define NPC_ATTACK_TYPE(ch) (ch)->npc->shared->attack_type #define NPC_ATTACK_N_O_DICE(ch) (ch)->npc->shared->damnodice #define NPC_ATTACK_SIZEDICE(ch) (ch)->npc->shared->damsizedice #define NPC_SPEC_PROC(ch) (ch)->npc->shared->func /* other npc only data */ #define NPC_SHARED(ch) (ch)->npc->shared #define NPC_FLAGS(ch) (ch)->npc->flag /* last_direction */ #define NPC_MEMORY(ch) (ch)->npc->memory /* other common character data */ #define CHAR_IN_ROOM(ch) (ch)->in_room #define CHAR_POSITION(ch) (ch)->position #define CHAR_PENALTY(ch) (ch)->lost_time #define CHAR_WEIGHT_CARRYING(ch)(ch)->carry_items #define CHAR_ITEMS_CARRYING(ch) (ch)->carry_weight #define CHAR_IDLE(ch) (ch)->idle_timer #define CHAR_APPLY(ch, i) (ch)->apply[(i)] #define CHAR_SAVE(ch, i) (ch)->apply_saving_throw[(i)] /* data, specials, points, string, affections */ #define CHAR_ABILITIES(ch) (ch)->abilities #define CHAR_PC(ch) (ch)->pc #define CHAR_NPC(ch) (ch)->npc /* *equipment[NUM_WEARS], *carrying, *carrying */ /* *next_in_room, *next, *next_fighting */ #define FIGHTING(ch) (ch)->fighting #define HUNTING(ch) (ch)->hunting /* *followers, *master, *mpact, mpactnum */ /* npc table elements */ #define NPC_TABLE_CHAR(i) (&(npc_proto[(i)].character)) #define NPC_TABLE_NPC(i) (&(npc_proto[(i)].npc_only)) #define NPC_TABLE_SHARED(i) (&(npc_proto[(i)].npc_only_shared)) ###################################################################
This archive was generated by hypermail 2b30 : 12/07/00 PST