void set_title(CharData * ch, char *title) { if (GET_TITLE(ch) != NULL) free(GET_TITLE(ch)); if (title == NULL){ char *the = "the "; title = calloc( 1, (strlen( the ) + strlen( READ_TITLE(ch))+1)); strcpy( title, the ); GET_TITLE(ch) = strcat( title, READ_TITLE(ch)); }/* if */ else { GET_TITLE(ch) = str_dup(title); }/* else */ }/* set_title */
void set_title(struct char_data * ch, char *title) { if (title == NULL) { if (GET_SEX(ch) == SEX_FEMALE) title = title_female(GET_CLASS(ch), GET_LEVEL(ch)); else title = title_male(GET_CLASS(ch), GET_LEVEL(ch)); } if (strlen(title) > MAX_TITLE_LENGTH) title[MAX_TITLE_LENGTH] = '\0'; if (GET_TITLE(ch) != NULL) free(GET_TITLE(ch)); GET_TITLE(ch) = str_dup(title); }
/* * Read in a char. */ int fread_char( struct char_data *ch, FILE *fp ) { int error_count = 0; char *word; char buf [ MAX_STRING_LENGTH ]; struct affected_type *paf; int sn; int i; int j; int status; int status1; char *p; int tmpi; int num_keys; int last_key = 0; char def_sdesc [] = "Your short description was corrupted."; char def_ldesc [] = "Your long description was corrupted."; char def_desc [] = "Your description was corrupted."; char def_title [] = "Your title was corrupted."; struct key_data key_tab [] = { { "ShtDsc", TRUE, (int) &def_sdesc, { &GET_SHORT_DESC(ch), NULL } }, { "LngDsc", TRUE, (int) &def_ldesc, { &GET_LONG_DESC(ch), NULL } }, { "Dscr", TRUE, (int) &def_desc, { &GET_DESCRIPTION(ch), NULL } }, { "Sx", FALSE, SEX_MALE, { &GET_SEX(ch), NULL } }, { "Race", FALSE, MAND, { &GET_RACE(ch), NULL } }, { "Lvl", FALSE, MAND, { &GET_LEVEL(ch), NULL } }, { "Trst", FALSE, 0, { &GET_TRUST(ch), NULL } }, { "HpMnMv", FALSE, MAND, { &GET_HIT(ch), &GET_MAX_HIT(ch), &GET_MANA(ch), &GET_MAX_MANA(ch), &GET_MOVE(ch), &GET_MAX_MOVE(ch), NULL } }, { "Gold", FALSE, 0, { &GET_GOLD(ch), NULL } }, { "Exp", FALSE, MAND, { &GET_EXP(ch), NULL } }, { "Act", FALSE, DEFLT, { &PLR_FLAGS(ch), NULL } }, { "Act2", FALSE, DEFLT, { &PLR2_FLAGS(ch), NULL } }, { "AffdBy", FALSE, 0, { &AFF_FLAGS(ch), NULL } }, { "AffdBy2", FALSE, 0, { &AFF2_FLAGS(ch), NULL } }, { "Pref", FALSE, 0, { &PRF_FLAGS(ch), NULL } }, { "Pref2", FALSE, 0, { &PRF2_FLAGS(ch), NULL } }, { "Pos", FALSE, POS_STANDING, { &GET_POS(ch), NULL } }, { "Prac", FALSE, MAND, { &GET_PRACTICES(ch), NULL } }, { "PAlign", FALSE, 0, { &GET_PERMALIGN(ch), NULL } }, { "CAlign", FALSE, 0, { &GET_ALIGNMENT(ch), NULL } }, { "Ttle", TRUE, (int) &def_title, { &GET_TITLE(ch), NULL } }, #if 0 { "SavThr", FALSE, MAND, { &ch->saving_throw, NULL } }, { "Hit", FALSE, MAND, { &ch->hitroll, NULL } }, { "Dam", FALSE, MAND, { &ch->damroll, NULL } }, { "Armr", FALSE, MAND, { &ch->armor, NULL } }, { "Wimp", FALSE, 10, { &ch->wimpy, NULL } }, { "Deaf", FALSE, 0, { &ch->deaf, NULL } }, { "Immskll",TRUE, DEFLT, { &ch->pcdata->immskll, NULL } }, { "AtrPrm", FALSE, MAND, { &ch->pcdata->perm_str, &ch->pcdata->perm_int, &ch->pcdata->perm_wis, &ch->pcdata->perm_dex, &ch->pcdata->perm_con, NULL } }, { "AtrMd", FALSE, MAND, { &ch->pcdata->mod_str, &ch->pcdata->mod_int, &ch->pcdata->mod_wis, &ch->pcdata->mod_dex, &ch->pcdata->mod_con, NULL } }, { "Cond", FALSE, DEFLT, { &ch->pcdata->condition [0], &ch->pcdata->condition [1], &ch->pcdata->condition [2], NULL } }, { "Pglen", FALSE, 20, { &ch->pcdata->pagelen, NULL } }, { "Playd", FALSE, 0, { &ch->played, NULL } }, #endif { "Paswd", TRUE, MAND, { &GET_PASSWD(ch), NULL } }, { "Poofin", TRUE, DEFLT, { &POOFIN(ch), NULL } }, { "Poofout", TRUE, DEFLT, { &POOFOUT(ch), NULL } }, { "\0", FALSE, 0 } }; for ( num_keys = 0; *key_tab [num_keys].key; ) num_keys++; for ( ; !feof (fp) ; ) { word = fread_word_stat( fp, &status ); if ( !word ) { log( "fread_char: Error reading key. EOF?" ); fread_to_eol( fp ); break; } /* This little diddy searches for the keyword from the last keyword found */ for ( i = last_key; i < last_key + num_keys && str_cmp (key_tab [i % num_keys].key, word); ) i++; i = i % num_keys; if ( !str_cmp (key_tab [i].key, word) ) last_key = i; else i = num_keys; if ( *key_tab [i].key ) /* Key entry found in key_tab */ { if ( key_tab [i].string == SPECIFIED ) log( "Key already specified." ); /* Entry is a string */ else if ( key_tab [i].string ) { if ( ( p = fread_string( fp, (char*)&status ) ) && !status ) { free( *(char **)key_tab [i].ptrs [0] ); *(char **)key_tab [i].ptrs [0] = p; } } /* Entry is an integer */ else for ( j = 0; key_tab [i].ptrs [j]; j++ ) { tmpi = fread_number_stat( fp, &status ); if ( !status ) *(int *)key_tab [i].ptrs [j] = tmpi; } if ( status ) { fread_to_eol( fp ); continue; } else key_tab [i].string = SPECIFIED; } else if ( *word == '*' || !str_cmp( word, "Nm" ) ) fread_to_eol( fp ); else if ( !str_cmp( word, "End" ) ) break; else if ( !str_cmp( word, "Room" ) ) { ch->in_room = fread_number_stat( fp, &status ); if ( !ch->in_room ) ch->in_room = NOWHERE; } else if ( !str_cmp( word, "Race" ) ) { i = race_lookup( fread_string( fp, (char*)&status ) ); if ( status ) log( "Fread_char: Unknown Race." ); else GET_RACE(ch) = i; } else if ( !str_cmp( word, "Skill" ) ) { i = fread_number_stat( fp, &status ); sn = skill_lookup( fread_word_stat( fp, &status1 ) ); if ( status || status1 ) { log( "Fread_char: Error reading skill." ); fread_to_eol( fp ); continue; } if ( sn < 0 ) log( "Fread_char: unknown skill." ); else GET_SKILL(ch, sn) = i; } else if ( !str_cmp ( word, "Afft" ) ) { int status; CREATE(paf, struct affected_type, 1); memset(paf, 0, sizeof( struct affected_type )); paf->type = skill_lookup( fread_string( fp, (char*)&status ) ); paf->duration = fread_number_stat( fp, &status ); paf->modifier = fread_number_stat( fp, &status ); paf->location = fread_number_stat( fp, &status ); paf->bitvector = fread_number_stat( fp, &status ); paf->next = ch->affected; ch->affected = paf; } else {
/* * Load a char and inventory into a new ch structure. */ bool load_char_obj( struct descriptor_data * d, const char * name ) { FILE *fp; struct char_data *ch; char strsave [ MAX_INPUT_LENGTH ]; bool found; char sorry_player [] = "********************************************************\n\r" "** One or more of the critical fields in your player **\n\r" "** file were corrupted since you last played. Please **\n\r" "** contact an administrator or programmer to **\n\r" "** investigate the recovery of your characters. **\n\r" "********************************************************\n\r"; char sorry_object [] = "********************************************************\n\r" "** One or more of the critical fields in your player **\n\r" "** file were corrupted leading to the loss of one or **\n\r" "** more of your possessions. **\n\r" "********************************************************\n\r"; char sorry_alias [] = "********************************************************\n\r" "** One or more of the critical fields in your player **\n\r" "** file were corrupted leading to the loss of one or **\n\r" "** more of your aliases. **\n\r" "********************************************************\n\r"; ch = new_character( TRUE ); d->character = ch; GET_DESC(ch) = d; ch->player.name = str_dup( name ); /* ch->pcdata->prompt = str_dup( daPrompt ); ch->last_note = 0; */ strcpy( GET_PASSWD(ch), "" ); POOFIN(ch) = str_dup( "" ); POOFOUT(ch) = str_dup( "" ); GET_TITLE(ch) = str_dup( "" ); GET_STR(ch) = 10; GET_ADD(ch) = 10; GET_INT(ch) = 10; GET_WIS(ch) = 10; GET_DEX(ch) = 10; GET_CON(ch) = 10; GET_CHA(ch) = 10; GET_WILL(ch) = 10; GET_COND(ch, DRUNK) = 48; GET_COND(ch, FULL) = 48; GET_COND(ch, THIRST) = 48; GET_COND(ch, TIRED) = 48; // ch->pcdata->switched = FALSE; found = FALSE; fclose( fpReserve ); /* parsed player file directories by Yaz of 4th Realm */ /* decompress if .gz file exists - Thx Alander */ sprintf( strsave, "%s/%s/%s%s", PLAYER_DIR, player_dir( GET_NAME(ch) ), capitalize( GET_NAME(ch) ), ".gz" ); if ( ( fp = fopen( strsave, "r" ) ) ) { char buf [ MAX_STRING_LENGTH ]; fclose( fp ); sprintf( buf, "gzip -dfq %s", strsave ); system( buf ); } sprintf( strsave, "%s/%s/%s", PLAYER_DIR, player_dir( GET_NAME(ch) ), capitalize( GET_NAME(ch) ) ); if ( ( fp = fopen( strsave, "r" ) ) ) { char buf[ MAX_STRING_LENGTH ]; int iNest; for ( iNest = 0; iNest < MAX_NEST; iNest++ ) rgObjNest[iNest] = NULL; found = TRUE; for ( ; ; ) { char *word; char letter; int status; letter = fread_letter( fp ); if ( letter == '*' ) { fread_to_eol( fp ); continue; } if ( letter != '#' ) { log( "Load_char_obj: # not found." ); break; } word = fread_word_stat( fp, &status ); if ( !str_cmp( word, "PLAYER" ) ) { if ( fread_char ( ch, fp ) ) { sprintf( buf, "Load_char_obj: %s section PLAYER corrupt.\n\r", name ); log( buf ); SEND_TO_Q( sorry_player, d ); /* * In case you are curious, * it is ok to leave ch alone for close_socket * to free. * We want to now kick the bad character out as * what we are missing are MANDATORY fields. -Kahn */ SET_BIT( PRF_FLAGS(ch), PLR_DELETED ); return TRUE; } } else if ( !str_cmp( word, "OBJECT" ) ) { if ( !fread_obj_char( ch, fp ) ) { sprintf( buf, "Load_char_obj: %s section OBJECT corrupt.\n\r", name ); log( buf ); SEND_TO_Q( sorry_object, d ); return FALSE; } } else if ( !str_cmp( word, "ALIAS" ) ) { if ( !fread_alias( ch, fp ) ) { sprintf( buf, "Load_char_obj: %s section ALIAS corrupt.\n\r", name ); log( buf ); SEND_TO_Q( sorry_alias, d ); return FALSE; } } else if ( !str_cmp( word, "END" ) ) break; else { log( "Load_char_obj: bad section." ); break; } } /* for */ fclose( fp ); } fpReserve = fopen( NULL_FILE, "r" ); if ( found ) rent_adjust( d->character ); return found; }
/* * Write the char to the file. * * @param ch the character to be written * @param fp the file to write to */ void fwrite_char( struct char_data *ch, FILE *fp ) { extern struct race_data * races; struct affected_type *paf; int sn, i; fprintf( fp, "#%s\n", IS_NPC( ch ) ? "MOB" : "PLAYER" ); fprintf( fp, "Name %s~\n", GET_NAME(ch) ); fprintf( fp, "ShtDsc %s~\n", GET_SHORT_DESC(ch) ? GET_SHORT_DESC(ch) : "" ); fprintf( fp, "LngDsc %s~\n", GET_LONG_DESC(ch) ? GET_LONG_DESC(ch) : "" ); fprintf( fp, "Dscr %s~\n", GET_DESCRIPTION(ch) ? GET_DESCRIPTION(ch) : "" ); // fprintf( fp, "Prmpt %s~\n", ch->pcdata->prompt ); fprintf( fp, "Sx %d\n", GET_SEX(ch) ); fprintf( fp, "Race %s~\n", races[ (int)GET_RACE(ch) ].name ); fprintf( fp, "Lvl %d\n", GET_LEVEL(ch) ); fprintf( fp, "Trst %d\n", GET_TRUST(ch) ); /* fprintf( fp, "Playd %ld\n", GET_PLAYED(ch) + (int)( time( 0 ) - GET_LOGON(ch) ) ); */ // fprintf( fp, "Note %ld\n", (unsigned long)ch->last_note ); fprintf( fp, "Room %ld\n", ( ch->in_room == NOWHERE && ch->was_in_room ) ? ch->was_in_room : ch->in_room ); fprintf( fp, "HpMnMv %d %d %d %d %d %d\n", GET_HIT(ch), GET_MAX_HIT(ch), GET_MANA(ch), GET_MAX_MANA(ch), GET_MOVE(ch), GET_MAX_MOVE(ch) ); fprintf( fp, "Gold %ld\n", GET_GOLD(ch) ); fprintf( fp, "Exp %ld\n", GET_EXP(ch) ); fprintf( fp, "Act %lld\n", PLR_FLAGS(ch) ); fprintf( fp, "Act2 %lld\n", PLR2_FLAGS(ch) ); fprintf( fp, "Pref %lld\n", PRF_FLAGS(ch) ); fprintf( fp, "Pref2 %lld\n", PRF2_FLAGS(ch) ); fprintf( fp, "AffdBy %lld\n", AFF_FLAGS(ch) ); fprintf( fp, "AffdBy2 %lld\n", AFF2_FLAGS(ch) ); /* Bug fix from Alander */ fprintf( fp, "Pos %d\n", GET_POS(ch) == POS_FIGHTING ? POS_STANDING : GET_POS(ch) ); fprintf( fp, "Prac %d\n", GET_PRACTICES(ch) ); fprintf( fp, "PAlign %d\n", GET_PERMALIGN(ch) ); fprintf( fp, "CAlign %d\n", GET_ALIGNMENT(ch) ); fprintf( fp, "SavThr " ); for ( i = 0; i < NUM_SAVES; i++ ) fprintf( fp, "%d%s", GET_SAVE(ch, i), (i != NUM_SAVES-1 ? ", " : "\n") ); fprintf( fp, "Hitroll %d\n", GET_HITROLL(ch) ); fprintf( fp, "Damroll %d\n", GET_DAMROLL(ch) ); fprintf( fp, "Armr " ); for ( i = 0; i < ARMOR_LIMIT; i++ ) fprintf( fp, "%d%s", GET_AC(ch, i), (i != ARMOR_LIMIT-1 ? ", " : "\n") ); fprintf( fp, "Wimp %d\n", GET_WIMP_LEV(ch) ); if ( IS_NPC( ch ) ) { fprintf( fp, "Vnum %ld\n", GET_MOB_VNUM(ch) ); } else { fprintf( fp, "Paswd %s~\n", GET_PASSWD(ch) ); fprintf( fp, "Poofin %s~\n", POOFIN(ch) ? POOFIN(ch) : "" ); fprintf( fp, "Poofout %s~\n", POOFOUT(ch) ? POOFOUT(ch) : "" ); fprintf( fp, "Ttle %s~\n", GET_TITLE(ch) ? GET_TITLE(ch) : "" ); fprintf( fp, "AtrPrm %d/%d %d %d %d %d %d %d\n", ch->real_abils.str, ch->real_abils.str_add, ch->real_abils.intel, ch->real_abils.wis, ch->real_abils.dex, ch->real_abils.con, ch->real_abils.cha, ch->real_abils.will ); fprintf( fp, "AtrMd %d/%d %d %d %d %d %d %d\n", ch->aff_abils.str, ch->aff_abils.str_add, ch->aff_abils.intel, ch->aff_abils.wis, ch->aff_abils.dex, ch->aff_abils.con, ch->aff_abils.cha, ch->aff_abils.will ); fprintf( fp, "Conditions " ); for ( i = 0; i < MAX_COND; i++ ) fprintf( fp, "%d%s", GET_COND(ch, i), (i != MAX_COND-1 ? ", " : "\n") ); fprintf( fp, "Addictions " ); for ( i = 0; i < MAX_COND; i++ ) fprintf( fp, "%d%s", GET_ADDICT(ch, i), (i != MAX_COND-1 ? ", " : "\n") ); for ( sn = 0; sn < MAX_SKILLS; sn++ ) { if ( skill_name( sn ) && strcmp( skill_name( sn ), "!UNUSED!" ) && GET_SKILL(ch, sn) > 0 ) { fprintf( fp, "Skill %d '%s'\n", GET_SKILL(ch, sn), skill_name( sn ) ); } } } for ( paf = ch->affected; paf; paf = paf->next ) { fprintf( fp, "Afft %18s~ %3d %3d %3d %lld\n", skill_name( paf->type ), paf->duration, paf->modifier, paf->location, paf->bitvector ); } for ( paf = ch->affected2; paf; paf = paf->next ) { fprintf( fp, "Afft2 %18s~ %3d %3d %3d %lld\n", skill_name( paf->type ), paf->duration, paf->modifier, paf->location, paf->bitvector ); } fprintf( fp, "End\n\n" ); return; }
void save_player_to_file(struct creature *ch, const char *path) { void expire_old_grievances(struct creature *); // Save vital statistics FILE *ouf; char *tmp_path; struct alias_data *cur_alias; int idx; int hit = GET_HIT(ch), mana = GET_MANA(ch), move = GET_MOVE(ch); tmp_path = tmp_sprintf("%s.tmp", path); ouf = fopen(tmp_path, "w"); if (!ouf) { fprintf(stderr, "Unable to open XML player file for save.[%s] (%s)\n", path, strerror(errno)); return; } struct aff_stash *aff_stash = stash_creature_affects(ch); expire_old_grievances(ch); fprintf(ouf, "<creature name=\"%s\" idnum=\"%ld\">\n", GET_NAME(ch), ch->char_specials.saved.idnum); fprintf(ouf, "<points hit=\"%d\" mana=\"%d\" move=\"%d\" maxhit=\"%d\" maxmana=\"%d\" maxmove=\"%d\"/>\n", ch->points.hit, ch->points.mana, ch->points.move, ch->points.max_hit, ch->points.max_mana, ch->points.max_move); fprintf(ouf, "<money gold=\"%" PRId64 "\" cash=\"%" PRId64 "\" xp=\"%d\"/>\n", ch->points.gold, ch->points.cash, ch->points.exp); fprintf(ouf, "<stats level=\"%d\" sex=\"%s\" race=\"%s\" height=\"%d\" weight=\"%f\" align=\"%d\"/>\n", GET_LEVEL(ch), genders[(int)GET_SEX(ch)], race_name_by_idnum(GET_RACE(ch)), GET_HEIGHT(ch), GET_WEIGHT(ch), GET_ALIGNMENT(ch)); fprintf(ouf, "<class name=\"%s\"", class_names[GET_CLASS(ch)]); if (GET_REMORT_CLASS(ch) != CLASS_UNDEFINED) fprintf(ouf, " remort=\"%s\"", class_names[GET_REMORT_CLASS(ch)]); if (GET_REMORT_GEN(ch) > 0) fprintf(ouf, " gen=\"%d\"", GET_REMORT_GEN(ch)); if (IS_CYBORG(ch)) { if (GET_OLD_CLASS(ch) != -1) fprintf(ouf, " subclass=\"%s\"", borg_subchar_class_names[GET_OLD_CLASS(ch)]); if (GET_TOT_DAM(ch)) fprintf(ouf, " total_dam=\"%d\"", GET_TOT_DAM(ch)); if (GET_BROKE(ch)) fprintf(ouf, " broken=\"%d\"", GET_BROKE(ch)); } if (GET_CLASS(ch) == CLASS_MAGE && GET_SKILL(ch, SPELL_MANA_SHIELD) > 0) { fprintf(ouf, " manash_low=\"%ld\" manash_pct=\"%ld\"", ch->player_specials->saved.mana_shield_low, ch->player_specials->saved.mana_shield_pct); } fprintf(ouf, "/>\n"); fprintf(ouf, "<time birth=\"%ld\" death=\"%ld\" played=\"%ld\" last=\"%ld\"/>\n", ch->player.time.birth, ch->player.time.death, ch->player.time.played, ch->player.time.logon); fprintf(ouf, "<carnage pkills=\"%d\" akills=\"%d\" mkills=\"%d\" deaths=\"%d\" reputation=\"%d\"", GET_PKILLS(ch), GET_ARENAKILLS(ch), GET_MOBKILLS(ch), GET_PC_DEATHS(ch), ch->player_specials->saved.reputation); fprintf(ouf, "/>\n"); fprintf(ouf, "<attr str=\"%d\" int=\"%d\" wis=\"%d\" dex=\"%d\" con=\"%d\" cha=\"%d\"/>\n", ch->real_abils.str, ch->real_abils.intel, ch->real_abils.wis, ch->real_abils.dex, ch->real_abils.con, ch->real_abils.cha); fprintf(ouf, "<condition hunger=\"%d\" thirst=\"%d\" drunk=\"%d\"/>\n", GET_COND(ch, FULL), GET_COND(ch, THIRST), GET_COND(ch, DRUNK)); fprintf(ouf, "<player wimpy=\"%d\" lp=\"%d\" clan=\"%d\"/>\n", GET_WIMP_LEV(ch), GET_LIFE_POINTS(ch), GET_CLAN(ch)); if (ch->desc) ch->player_specials->desc_mode = ch->desc->input_mode; if (ch->player_specials->rentcode == RENT_CREATING || ch->player_specials->rentcode == RENT_REMORTING) { fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" " "currency=\"%d\" state=\"%s\"/>\n", ch->player_specials->rentcode, ch->player_specials->rent_per_day, ch->player_specials->rent_currency, desc_modes[(int)ch->player_specials->desc_mode]); } else { fprintf(ouf, "<rent code=\"%d\" perdiem=\"%d\" currency=\"%d\"/>\n", ch->player_specials->rentcode, ch->player_specials->rent_per_day, ch->player_specials->rent_currency); } fprintf(ouf, "<home town=\"%d\" homeroom=\"%d\" loadroom=\"%d\"/>\n", GET_HOME(ch), GET_HOMEROOM(ch), GET_LOADROOM(ch)); fprintf(ouf, "<quest"); if (GET_QUEST(ch)) fprintf(ouf, " current=\"%d\"", GET_QUEST(ch)); if (GET_LEVEL(ch) >= LVL_IMMORT) fprintf(ouf, " allowance=\"%d\"", GET_QUEST_ALLOWANCE(ch)); if (GET_IMMORT_QP(ch) != 0) fprintf(ouf, " points=\"%d\"", GET_IMMORT_QP(ch)); fprintf(ouf, "/>\n"); fprintf(ouf, "<bits flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\"/>\n", ch->char_specials.saved.act, ch->player_specials->saved.plr2_bits); if (PLR_FLAGGED(ch, PLR_FROZEN)) { fprintf(ouf, "<frozen thaw_time=\"%d\" freezer_id=\"%d\"/>\n", ch->player_specials->thaw_time, ch->player_specials->freezer_id); } fprintf(ouf, "<prefs flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" tongue=\"%s\"/>\n", ch->player_specials->saved.pref, ch->player_specials->saved.pref2, tongue_name(GET_TONGUE(ch))); fprintf(ouf, "<affects flag1=\"%" PRIx32 "\" flag2=\"%" PRIx32 "\" flag3=\"%" PRIx32 "\"/>\n", ch->char_specials.saved.affected_by, ch->char_specials.saved.affected2_by, ch->char_specials.saved.affected3_by); for (idx = 0; idx < MAX_WEAPON_SPEC; idx++) { if (GET_WEAP_SPEC(ch, idx).level > 0) fprintf(ouf, "<weaponspec vnum=\"%d\" level=\"%d\"/>\n", GET_WEAP_SPEC(ch, idx).vnum, GET_WEAP_SPEC(ch, idx).level); } if (GET_TITLE(ch) && *GET_TITLE(ch)) { fprintf(ouf, "<title>%s</title>\n", xmlEncodeTmp(GET_TITLE(ch))); } if (GET_LEVEL(ch) >= 50) { fprintf(ouf, "<immort badge=\"%s\" qlog=\"%d\" invis=\"%d\"/>\n", xmlEncodeSpecialTmp(BADGE(ch)), GET_QLOG_LEVEL(ch), GET_INVIS_LVL(ch)); if (POOFIN(ch) && *POOFIN(ch)) fprintf(ouf, "<poofin>%s</poofin>\n", xmlEncodeTmp(POOFIN(ch))); if (POOFOUT(ch) && *POOFOUT(ch)) fprintf(ouf, "<poofout>%s</poofout>\n", xmlEncodeTmp(POOFOUT(ch))); } if (ch->player.description && *ch->player.description) { fprintf(ouf, "<description>%s</description>\n", xmlEncodeTmp(tmp_gsub(tmp_gsub(ch->player.description, "\r\n", "\n"), "\r", ""))); } for (cur_alias = ch->player_specials->aliases; cur_alias; cur_alias = cur_alias->next) fprintf(ouf, "<alias type=\"%d\" alias=\"%s\" replace=\"%s\"/>\n", cur_alias->type, xmlEncodeSpecialTmp(cur_alias->alias), xmlEncodeSpecialTmp(cur_alias->replacement)); for (struct affected_type *cur_aff = aff_stash->saved_affs; cur_aff; cur_aff = cur_aff->next) fprintf(ouf, "<affect type=\"%d\" duration=\"%d\" modifier=\"%d\" location=\"%d\" level=\"%d\" instant=\"%s\" affbits=\"%lx\" index=\"%d\" owner=\"%ld\"/>\n", cur_aff->type, cur_aff->duration, cur_aff->modifier, cur_aff->location, cur_aff->level, (cur_aff->is_instant) ? "yes" : "no", cur_aff->bitvector, cur_aff->aff_index, cur_aff->owner); if (!IS_IMMORT(ch)) { for (idx = 0; idx < MAX_SKILLS; idx++) if (ch->player_specials->saved.skills[idx] > 0) fprintf(ouf, "<skill name=\"%s\" level=\"%d\"/>\n", spell_to_str(idx), GET_SKILL(ch, idx)); write_tongue_xml(ch, ouf); for (GList * it = GET_RECENT_KILLS(ch); it; it = it->next) { struct kill_record *kill = it->data; fprintf(ouf, "<recentkill vnum=\"%d\" times=\"%d\"/>\n", kill->vnum, kill->times); } for (GList * it = GET_GRIEVANCES(ch); it; it = it->next) { struct grievance *grievance = it->data; fprintf(ouf, "<grievance time=\"%lu\" player=\"%d\" reputation=\"%d\" kind=\"%s\"/>\n", (long unsigned)grievance->time, grievance->player_id, grievance->rep, grievance_kind_descs[grievance->grievance]); } } if (IS_PC(ch) && ch->player_specials->tags) { GHashTableIter iter; char *key; g_hash_table_iter_init(&iter, ch->player_specials->tags); while (g_hash_table_iter_next(&iter, (gpointer *)&key, NULL)) { fprintf(ouf, "<tag tag=\"%s\"/>\n", key); } } fprintf(ouf, "</creature>\n"); fclose(ouf); // on success, move temp file on top of the old file rename(tmp_path, path); restore_creature_affects(ch, aff_stash); free(aff_stash); GET_HIT(ch) = MIN(GET_MAX_HIT(ch), hit); GET_MANA(ch) = MIN(GET_MAX_MANA(ch), mana); GET_MOVE(ch) = MIN(GET_MAX_MOVE(ch), move); }
void show_char_to_char(struct char_data *i, struct char_data *ch, int mode) { char buffer[MAX_STRING_LENGTH]; int j, found, percent; struct obj_data *tmp_obj; if (mode == 0) { if (IS_AFFECTED(i, AFF_HIDE) || !CAN_SEE(ch,i)) { if (IS_AFFECTED(ch, AFF_SENSE_LIFE)) send_to_char("You sense a hidden life form in the room.\n\r", ch); return; } if (!(i->player.long_descr)||(GET_POS(i) != i->specials.default_pos)) { /* A player char or a mobile without long descr, or not in default pos. */ if (!IS_NPC(i)) { strcpy(buffer,GET_NAME(i)); strcat(buffer," "); strcat(buffer,GET_TITLE(i)); } else { strcpy(buffer, i->player.short_descr); CAP(buffer); } if ( IS_AFFECTED(i,AFF_INVISIBLE)) strcat(buffer," (invisible)"); switch(GET_POS(i)) { case POSITION_STUNNED : strcat(buffer," is lying here, stunned."); break; case POSITION_INCAP : strcat(buffer," is lying here, incapacitated."); break; case POSITION_MORTALLYW: strcat(buffer," is lying here, mortally wounded."); break; case POSITION_DEAD : strcat(buffer," is lying here, dead."); break; case POSITION_STANDING : strcat(buffer," is standing here."); break; case POSITION_SITTING : strcat(buffer," is sitting here."); break; case POSITION_RESTING : strcat(buffer," is resting here."); break; case POSITION_SLEEPING : strcat(buffer," is sleeping here."); break; case POSITION_FIGHTING : if (i->specials.fighting) { strcat(buffer," is here, fighting "); if (i->specials.fighting == ch) strcat(buffer," YOU!"); else { if (i->in_room == i->specials.fighting->in_room) if (IS_NPC(i->specials.fighting)) strcat(buffer, i->specials.fighting->player.short_descr); else strcat(buffer, GET_NAME(i->specials.fighting)); else strcat(buffer, "someone who has already left."); } } else /* NIL fighting pointer */ strcat(buffer," is here struggling with thin air."); break; default : strcat(buffer," is floating here."); break; } if (IS_AFFECTED(ch, AFF_DETECT_EVIL)) { if (IS_EVIL(i)) strcat(buffer, " (Red Aura)"); } strcat(buffer,"\n\r"); send_to_char(buffer, ch); } else /* npc with long */ { if (IS_AFFECTED(i,AFF_INVISIBLE)) strcpy(buffer,"*"); else *buffer = '\0'; if (IS_AFFECTED(ch, AFF_DETECT_EVIL)) { if (IS_EVIL(i)) strcat(buffer, " (Red Aura)"); } strcat(buffer, i->player.long_descr); send_to_char(buffer, ch); } if (IS_AFFECTED(i,AFF_SANCTUARY)) act("$n glows with a bright light!", FALSE, i, 0, ch, TO_VICT); } else if (mode == 1) { if (i->player.description) send_to_char(i->player.description, ch); else { act("You see nothing special about $m.", FALSE, i, 0, ch, TO_VICT); } /* Show a character to another */ if (GET_MAX_HIT(i) > 0) percent = (100*GET_HIT(i))/GET_MAX_HIT(i); else percent = -1; /* How could MAX_HIT be < 1?? */ if (IS_NPC(i)) strcpy(buffer, i->player.short_descr); else strcpy(buffer, GET_NAME(i)); if (percent >= 100) strcat(buffer, " is in an excellent condition.\n\r"); else if (percent >= 90) strcat(buffer, " has a few scratches.\n\r"); else if (percent >= 75) strcat(buffer, " has some small wounds and bruises.\n\r"); else if (percent >= 50) strcat(buffer, " has quite a few wounds.\n\r"); else if (percent >= 30) strcat(buffer, " has some big nasty wounds and scratches.\n\r"); else if (percent >= 15) strcat(buffer, " looks pretty hurt.\n\r"); else if (percent >= 0) strcat(buffer, " is in an awful condition.\n\r"); else strcat(buffer, " is bleeding awfully from big wounds.\n\r"); send_to_char(buffer, ch); found = FALSE; for (j=0; j< MAX_WEAR; j++) { if (i->equipment[j]) { if (CAN_SEE_OBJ(ch,i->equipment[j])) { found = TRUE; } } } if (found) { act("\n\r$n is using:", FALSE, i, 0, ch, TO_VICT); for (j=0; j< MAX_WEAR; j++) { if (i->equipment[j]) { if (CAN_SEE_OBJ(ch,i->equipment[j])) { send_to_char(where[j],ch); show_obj_to_char(i->equipment[j],ch,1); } } } } if ((GET_CLASS(ch) == CLASS_THIEF) && (ch != i)) { found = FALSE; send_to_char("\n\rYou attempt to peek at the inventory:\n\r", ch); for(tmp_obj = i->carrying; tmp_obj; tmp_obj = tmp_obj->next_content) { if (CAN_SEE_OBJ(ch, tmp_obj) && (number(0,20) < GET_LEVEL(ch))) { show_obj_to_char(tmp_obj, ch, 1); found = TRUE; } } if (!found) send_to_char("You can't see anything.\n\r", ch); } } else if (mode == 2) { /* Lists inventory */ act("$n is carrying:", FALSE, i, 0, ch, TO_VICT); list_obj_to_char(i->carrying,ch,1,TRUE); } }