character.c
上传用户:tany51
上传日期:2013-06-12
资源大小:1397k
文件大小:17k
- /*
- * Copyright (C) 2000 Ross Combs (rocombs@cs.nmsu.edu)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- #define CHARACTER_INTERNAL_ACCESS
- #include "common/setup_before.h"
- #include <stdio.h>
- #ifdef HAVE_STDDEF_H
- # include <stddef.h>
- #else
- # ifndef NULL
- # define NULL ((void *)0)
- # endif
- #endif
- #ifdef STDC_HEADERS
- # include <stdlib.h>
- #else
- # ifdef HAVE_MALLOC_H
- # include <malloc.h>
- # endif
- #endif
- #ifdef HAVE_STRING_H
- # include <string.h>
- #else
- # ifdef HAVE_STRINGS_H
- # include <strings.h>
- # endif
- # ifdef HAVE_MEMORY_H
- # include <memory.h>
- # endif
- #endif
- #include "compat/memcpy.h"
- #include "compat/strcasecmp.h"
- #include "compat/strdup.h"
- #include <errno.h>
- #include "compat/strerror.h"
- #include "common/eventlog.h"
- #include "common/list.h"
- #include "compat/uint.h"
- #include "common/bnet_protocol.h"
- #include "account.h"
- #include "common/bn_type.h"
- #include "common/util.h"
- #include "character.h"
- #include "common/setup_after.h"
- static t_list * characterlist_head=NULL;
- static t_character_class bncharacter_class_to_character_class(t_uint8 class)
- {
- switch (class)
- {
- case D2CHAR_INFO_CLASS_AMAZON:
- return character_class_amazon;
- case D2CHAR_INFO_CLASS_SORCERESS:
- return character_class_sorceress;
- case D2CHAR_INFO_CLASS_NECROMANCER:
- return character_class_necromancer;
- case D2CHAR_INFO_CLASS_PALADIN:
- return character_class_paladin;
- case D2CHAR_INFO_CLASS_BARBARIAN:
- return character_class_barbarian;
- case D2CHAR_INFO_CLASS_DRUID:
- return character_class_druid;
- case D2CHAR_INFO_CLASS_ASSASSIN:
- return character_class_assassin;
- default:
- return character_class_none;
- }
- }
- /* Function unused
- static t_uint8 character_class_to_bncharacter_class(t_character_class class)
- {
- switch (class)
- {
- case character_class_amazon:
- return D2CHAR_INFO_CLASS_AMAZON;
- case character_class_sorceress:
- return D2CHAR_INFO_CLASS_SORCERESS;
- case character_class_necromancer:
- return D2CHAR_INFO_CLASS_NECROMANCER;
- case character_class_paladin:
- return D2CHAR_INFO_CLASS_PALADIN;
- case character_class_barbarian:
- return D2CHAR_INFO_CLASS_BARBARIAN;
- case character_class_druid:
- return D2CHAR_INFO_CLASS_DRUID;
- case character_class_assassin:
- return D2CHAR_INFO_CLASS_ASSASSIN;
- default:
- eventlog(eventlog_level_error,"character_class_to_bncharacter_class","got unknown class %d",(int)class);
- case character_class_none:
- return D2CHAR_INFO_FILLER;
- }
- }
- */
- static const char * character_class_to_classname (t_character_class class)
- {
- switch (class)
- {
- case character_class_amazon:
- return "Amazon";
- case character_class_sorceress:
- return "Sorceress";
- case character_class_necromancer:
- return "Necromancer";
- case character_class_paladin:
- return "Paladin";
- case character_class_barbarian:
- return "Barbarian";
- case character_class_druid:
- return "Druid";
- case character_class_assassin:
- return "Assassin";
- default:
- return "Unknown";
- }
- }
- static const char * character_expansion_to_expansionname (t_character_expansion expansion)
- {
- switch (expansion)
- {
- case character_expansion_classic:
- return "Classic";
- case character_expansion_lod:
- return "LordOfDestruction";
- default:
- return "Unknown";
- }
- }
- static void decode_character_data(t_character * ch)
- {
- ch->unknownb1 = D2CHAR_INFO_UNKNOWNB1;
- ch->unknownb2 = D2CHAR_INFO_UNKNOWNB2;
- ch->helmgfx = D2CHAR_INFO_FILLER;
- ch->bodygfx = D2CHAR_INFO_FILLER;
- ch->leggfx = D2CHAR_INFO_FILLER;
- ch->lhandweapon = D2CHAR_INFO_FILLER;
- ch->lhandgfx = D2CHAR_INFO_FILLER;
- ch->rhandweapon = D2CHAR_INFO_FILLER;
- ch->rhandgfx = D2CHAR_INFO_FILLER;
- ch->unknownb3 = D2CHAR_INFO_FILLER;
- ch->unknownb4 = D2CHAR_INFO_FILLER;
- ch->unknownb5 = D2CHAR_INFO_FILLER;
- ch->unknownb6 = D2CHAR_INFO_FILLER;
- ch->unknownb7 = D2CHAR_INFO_FILLER;
- ch->unknownb8 = D2CHAR_INFO_FILLER;
- ch->unknownb9 = D2CHAR_INFO_FILLER;
- ch->unknownb10 = D2CHAR_INFO_FILLER;
- ch->unknownb11 = D2CHAR_INFO_FILLER;
- ch->unknown1 = 0xffffffff;
- ch->unknown2 = 0xffffffff;
- ch->unknown3 = 0xffffffff;
- ch->unknown4 = 0xffffffff;
- ch->level = 0x01;
- ch->status = 0x80;
- ch->title = 0x80;
- ch->unknownb13 = 0x80;
- ch->emblembgc = 0x80;
- ch->emblemfgc = 0xff;
- ch->emblemnum = 0xff;
- ch->unknownb14 = D2CHAR_INFO_FILLER;
- /*
- b1 b2 hg bg lg lw lg rw rg b3 b4 b5 b6 b7 b8 b9 bA bB cl u1 u1 u1 u1 u2 u2 u2 u2 u3 u3 u3 u3 u4 u4 u4 u4 lv st ti bC eb ef en bD