Changeset 173
- Timestamp:
- 12/16/09 02:21:21 (9 months ago)
- Location:
- eoserv/trunk
- Files:
-
- 18 modified
-
admin.ini (modified) (1 diff)
-
src/character.cpp (modified) (1 diff)
-
src/eoclient.cpp (modified) (1 diff)
-
src/eoclient.hpp (modified) (1 diff)
-
src/eodata.cpp (modified) (4 diffs)
-
src/eodata.hpp (modified) (4 diffs)
-
src/eoserver.cpp (modified) (1 diff)
-
src/eoserver.hpp (modified) (1 diff)
-
src/handlers/Bank.cpp (modified) (1 diff)
-
src/handlers/Talk.cpp (modified) (3 diffs)
-
src/handlers/Warp.cpp (modified) (1 diff)
-
src/handlers/Welcome.cpp (modified) (2 diffs)
-
src/main.cpp (modified) (1 diff)
-
src/map.cpp (modified) (2 diffs)
-
src/npc.cpp (modified) (13 diffs)
-
src/npc.hpp (modified) (2 diffs)
-
src/world.cpp (modified) (1 diff)
-
src/world.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
eoserv/trunk/admin.ini
r171 r173 88 88 remap = 4 89 89 90 # Reloads pub files 91 # $repub 92 repub = 4 93 90 94 # Forces an arena launch on the current map 91 95 # $arena -
eoserv/trunk/src/character.cpp
r172 r173 836 836 { 837 837 builder.AddChar(npc->index); 838 builder.AddShort(npc-> data->id);838 builder.AddShort(npc->Data()->id); 839 839 builder.AddChar(npc->x); 840 840 builder.AddChar(npc->y); -
eoserv/trunk/src/eoclient.cpp
r171 r173 136 136 } 137 137 138 void EOClient::SendBuilderRaw(PacketBuilder &builder) 139 { 140 std::string packet(builder); 141 this->Send(packet); 142 } 143 138 144 EOClient::~EOClient() 139 145 { -
eoserv/trunk/src/eoclient.hpp
r171 r173 100 100 101 101 void SendBuilder(PacketBuilder &packet); 102 void SendBuilderRaw(PacketBuilder &packet); 102 103 103 104 // Stop doxygen generating a gigantic list of functions -
eoserv/trunk/src/eodata.cpp
r171 r173 21 21 #define SAFE_READ(buf, size, count, fh) if (std::fread(buf, size, count, fh) != static_cast<int>(count)) { std::fclose(fh); safe_fail(__LINE__); } 22 22 23 EIF::EIF(std::string filename) 24 { 23 void EIF::Read(std::string filename) 24 { 25 this->data.clear(); 26 25 27 std::FILE *fh = std::fopen(filename.c_str(), "rb"); 26 28 safe_fail_filename = filename.c_str(); … … 120 122 } 121 123 122 ENF::ENF(std::string filename) 123 { 124 void ENF::Read(std::string filename) 125 { 126 this->data.clear(); 127 124 128 std::FILE *fh = std::fopen(filename.c_str(), "rb"); 125 129 safe_fail_filename = filename.c_str(); … … 204 208 } 205 209 206 ESF::ESF(std::string filename) 207 { 210 void ESF::Read(std::string filename) 211 { 212 this->data.clear(); 213 208 214 std::FILE *fh = std::fopen(filename.c_str(), "rb"); 209 215 safe_fail_filename = filename.c_str(); … … 278 284 } 279 285 280 ECF::ECF(std::string filename) 281 { 286 void ECF::Read(std::string filename) 287 { 288 this->data.clear(); 289 282 290 std::FILE *fh = std::fopen(filename.c_str(), "rb"); 283 291 safe_fail_filename = filename.c_str(); -
eoserv/trunk/src/eodata.hpp
r171 r173 73 73 unsigned char len[2]; 74 74 PtrVector<EIF_Data> data; 75 EIF(std::string filename); 75 EIF(std::string filename) { Read(filename); } 76 void Read(std::string filename); 76 77 77 78 EIF_Data *Get(unsigned int id); … … 166 167 unsigned char len[2]; 167 168 PtrVector<ENF_Data> data; 168 ENF(std::string filename); 169 ENF(std::string filename) { Read(filename); } 170 void Read(std::string filename); 169 171 170 172 ENF_Data *Get(unsigned int id); … … 210 212 unsigned char len[2]; 211 213 PtrVector<ESF_Data> data; 212 ESF(std::string filename); 214 ESF(std::string filename) { Read(filename); } 215 void Read(std::string filename); 213 216 214 217 SCRIPT_REGISTER_REF(ESF) … … 239 242 unsigned char len[2]; 240 243 PtrVector<ECF_Data> data; 241 ECF(std::string filename); 244 ECF(std::string filename) { Read(filename); } 245 void Read(std::string filename); 242 246 243 247 SCRIPT_REGISTER_REF(ECF) -
eoserv/trunk/src/eoserver.cpp
r171 r173 145 145 this->sln = 0; 146 146 } 147 148 this->start = Timer::GetTime(); 147 149 } 148 150 -
eoserv/trunk/src/eoserver.hpp
r171 r173 29 29 public: 30 30 World *world; 31 double start; 31 32 32 33 EOServer(IPAddress addr, unsigned short port, util::array<std::string, 5> dbinfo, const Config &eoserv_config, const Config &admin_config) : Server(addr, port) -
eoserv/trunk/src/handlers/Bank.cpp
r171 r173 25 25 UTIL_PTR_VECTOR_FOREACH(this->player->character->map->npcs, NPC, npc) 26 26 { 27 if (npc->index == id && npc-> data->type == ENF::Bank)27 if (npc->index == id && npc->Data()->type == ENF::Bank) 28 28 { 29 29 this->player->character->bank_npc = *npc; -
eoserv/trunk/src/handlers/Talk.cpp
r171 r173 279 279 } 280 280 } 281 } 282 else if (command.length() >= 3 && command.compare(0,3,"rep") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["repub"])) 283 { 284 this->server->world->ReloadPub(); 281 285 } 282 286 else if (command.length() >= 1 && command.compare(0,1,"r") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["rehash"])) … … 371 375 std::exit(0); 372 376 } 373 else if (command.length() == 3 && command.compare(0,3,"obj") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["objects"]))377 else if (command.length() >= 3 && command.compare(0,3,"obj") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["objects"])) 374 378 { 375 379 std::string buffer = "Objects: "; … … 379 383 this->player->character->ServerMsg(buffer); 380 384 } 385 else if (command.length() >= 2 && command.compare(0,2,"up") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["uptime"])) 386 { 387 std::string buffer = "Server started "; 388 buffer += util::timeago(this->server->start, Timer::GetTime()); 389 this->player->character->ServerMsg(buffer); 390 } 381 391 else if (command.length() >= 1 && command.compare(0,1,"q") == 0 && this->player->character->admin >= static_cast<int>(this->server->world->admin_config["quake"])) 382 392 { -
eoserv/trunk/src/handlers/Warp.cpp
r171 r173 106 106 { 107 107 reply.AddChar(npc->index); 108 reply.AddShort(npc-> data->id);108 reply.AddShort(npc->Data()->id); 109 109 reply.AddChar(npc->x); 110 110 reply.AddChar(npc->y); -
eoserv/trunk/src/handlers/Welcome.cpp
r171 r173 296 296 { 297 297 reply.AddChar(npc->index); 298 reply.AddShort(npc-> data->id);298 reply.AddShort(npc->Data()->id); 299 299 reply.AddChar(npc->x); 300 300 reply.AddChar(npc->y); … … 335 335 { 336 336 case FILE_MAP: break; // Map file is pre-loaded in to the variable 337 case FILE_ITEM: filename = "./data/pub/dat001.eif"; replycode = INIT_FILE_EIF; fileid = 1; break;338 case FILE_NPC: filename = "./data/pub/dtn001.enf"; replycode = INIT_FILE_ENF; fileid = 1; break;339 case FILE_SPELL: filename = "./data/pub/dsl001.esf"; replycode = INIT_FILE_ESF; fileid = 1; break;340 case FILE_CLASS: filename = "./data/pub/dat001.ecf"; replycode = INIT_FILE_ECF; fileid = 1; break;337 case FILE_ITEM: filename = static_cast<std::string>(this->server->world->config["EIF"]); replycode = INIT_FILE_EIF; fileid = 1; break; 338 case FILE_NPC: filename = static_cast<std::string>(this->server->world->config["ENF"]); replycode = INIT_FILE_ENF; fileid = 1; break; 339 case FILE_SPELL: filename = static_cast<std::string>(this->server->world->config["ESF"]); replycode = INIT_FILE_ESF; fileid = 1; break; 340 case FILE_CLASS: filename = static_cast<std::string>(this->server->world->config["ECF"]); replycode = INIT_FILE_ECF; fileid = 1; break; 341 341 default: return false; 342 342 } -
eoserv/trunk/src/main.cpp
r172 r173 411 411 eoserv_config_default(aconfig, "evacuate" , 2); 412 412 eoserv_config_default(aconfig, "remap" , 4); 413 eoserv_config_default(aconfig, "repub" , 4); 413 414 eoserv_config_default(aconfig, "arena" , 1); 414 415 eoserv_config_default(aconfig, "shutdown" , 4); -
eoserv/trunk/src/map.cpp
r172 r173 1275 1275 UTIL_PTR_VECTOR_FOREACH(this->npcs, NPC, npc) 1276 1276 { 1277 if ((npc-> data->type == ENF::Passive || npc->data->type == ENF::Aggressive || from->admin > static_cast<int>(this->world->admin_config["killnpcs"]))1277 if ((npc->Data()->type == ENF::Passive || npc->Data()->type == ENF::Aggressive || from->admin > static_cast<int>(this->world->admin_config["killnpcs"])) 1278 1278 && npc->alive && npc->x == target_x && npc->y == target_y) 1279 1279 { … … 1295 1295 1296 1296 hit_rate += int(from->accuracy / 2.0); 1297 hit_rate -= int(double(npc-> data->evade) / 2.0 * mobrate);1297 hit_rate -= int(double(npc->Data()->evade) / 2.0 * mobrate); 1298 1298 hit_rate = std::min(std::max(hit_rate, 20), 100); 1299 1299 1300 1300 int origamount = amount; 1301 amount -= int(double(npc-> data->armor) / 3.0 * mobrate);1301 amount -= int(double(npc->Data()->armor) / 3.0 * mobrate); 1302 1302 1303 1303 amount = std::max(amount, int(std::ceil(double(origamount) * 0.1))); -
eoserv/trunk/src/npc.cpp
r171 r173 49 49 this->walk_idle_for = 0; 50 50 51 this->data = map->world->enf->Get(id);52 53 51 if (spawn_type == 7) 54 52 { … … 160 158 } 161 159 } 160 } 161 162 ENF_Data *NPC::Data() 163 { 164 return this->map->world->enf->Get(id); 162 165 } 163 166 … … 213 216 214 217 this->alive = true; 215 this->hp = this-> data->hp;218 this->hp = this->Data()->hp; 216 219 this->last_act = Timer::GetTime(); 217 220 this->act_speed = speed_table[this->spawn_type]; … … 265 268 } 266 269 267 if (this-> data->type == ENF::Aggressive && !attacker)270 if (this->Data()->type == ENF::Aggressive && !attacker) 268 271 { 269 272 Character *closest = 0; … … 413 416 builder.AddShort(this->index); 414 417 builder.AddThree(amount); 415 builder.AddShort(int(double(this->hp) / double(this-> data->hp) * 100.0));418 builder.AddShort(int(double(this->hp) / double(this->Data()->hp) * 100.0)); 416 419 builder.AddChar(1); // ? 417 420 … … 483 486 case 2: 484 487 { 485 int rewarded_hp = util::rand(0, this-> data->hp);488 int rewarded_hp = util::rand(0, this->Data()->hp); 486 489 int count_hp = 0; 487 490 UTIL_PTR_LIST_FOREACH(this->damagelist, NPC_Opponent, opponent) … … 534 537 builder.SetID(PACKET_NPC, PACKET_SPEC); 535 538 536 if (this-> data->exp != 0)539 if (this->Data()->exp != 0) 537 540 { 538 541 if (findopp) … … 544 547 if (*character == from) 545 548 { 546 reward = int(std::ceil(double(this-> data->exp) * exprate));549 reward = int(std::ceil(double(this->Data()->exp) * exprate)); 547 550 548 551 if (reward > 0) … … 570 573 if (*character == most_damage) 571 574 { 572 reward = int(std::ceil(double(this-> data->exp) * exprate));575 reward = int(std::ceil(double(this->Data()->exp) * exprate)); 573 576 574 577 if (reward > 0) … … 594 597 595 598 case 2: 596 reward = int(std::ceil(double(this-> data->exp) * exprate * (double(findopp->damage) / double(this->totaldamage))));599 reward = int(std::ceil(double(this->Data()->exp) * exprate * (double(findopp->damage) / double(this->totaldamage)))); 597 600 598 601 if (reward > 0) … … 618 621 619 622 case 3: 620 reward = int(std::ceil(double(this-> data->exp) * exprate * (double(this->damagelist.size()) / 1.0)));623 reward = int(std::ceil(double(this->Data()->exp) * exprate * (double(this->damagelist.size()) / 1.0))); 621 624 622 625 if (reward > 0) … … 713 716 double mobrate = this->map->world->config["MobRate"]; 714 717 715 int amount = util::rand(this-> data->mindam, this->data->maxdam + static_cast<int>(this->map->world->config["NPCAdjustMaxDam"]));718 int amount = util::rand(this->Data()->mindam, this->Data()->maxdam + static_cast<int>(this->map->world->config["NPCAdjustMaxDam"])); 716 719 717 720 int hit_rate = 120; … … 727 730 } 728 731 729 hit_rate += int(double(this-> data->accuracy) / 2.0 * mobrate);732 hit_rate += int(double(this->Data()->accuracy) / 2.0 * mobrate); 730 733 hit_rate -= int(double(target->evade) / 2.0); 731 734 hit_rate = std::min(std::max(hit_rate, 20), 100); -
eoserv/trunk/src/npc.hpp
r171 r173 69 69 bool temporary; 70 70 short id; 71 ENF_Data *data;72 71 unsigned char x, y; 73 72 Direction direction; … … 96 95 NPC(Map *map, short id, unsigned char x, unsigned char y, unsigned char spawn_type, short spawn_time, unsigned char index, bool temporary = false); 97 96 97 ENF_Data *Data(); 98 98 99 bool SpawnReady(); 99 100 -
eoserv/trunk/src/world.cpp
r171 r173 377 377 } 378 378 379 void World::ReloadPub() 380 { 381 this->eif->Read(this->config["EIF"]); 382 this->enf->Read(this->config["ENF"]); 383 this->esf->Read(this->config["ESF"]); 384 this->ecf->Read(this->config["ECF"]); 385 386 std::string filename; 387 std::FILE *fh; 388 InitReply replycode; 389 390 for (int i = 0; i < 4; ++i) 391 { 392 std::string content; 393 394 switch (i) 395 { 396 case 0: filename = static_cast<std::string>(this->config["EIF"]); replycode = INIT_FILE_EIF; break; 397 case 1: filename = static_cast<std::string>(this->config["ENF"]); replycode = INIT_FILE_ENF; break; 398 case 2: filename = static_cast<std::string>(this->config["ESF"]); replycode = INIT_FILE_ESF; break; 399 case 3: filename = static_cast<std::string>(this->config["ECF"]); replycode = INIT_FILE_ECF; break; 400 } 401 402 fh = std::fopen(filename.c_str(), "rb"); 403 404 if (!fh) 405 { 406 Console::Err("Could not load file: %s", filename.c_str()); 407 std::exit(1); 408 } 409 410 do { 411 char buf[4096]; 412 int len = std::fread(buf, sizeof(char), 4096, fh); 413 content.append(buf, len); 414 } while (!std::feof(fh)); 415 416 std::fclose(fh); 417 418 PacketBuilder builder(0); 419 builder.AddChar(replycode); 420 builder.AddChar(1); // fileid 421 builder.AddString(content); 422 423 UTIL_PTR_VECTOR_FOREACH(this->characters, Character, character) 424 { 425 character->player->client->SendBuilderRaw(builder); 426 } 427 } 428 429 UTIL_PTR_VECTOR_FOREACH(this->characters, Character, character) 430 { 431 character->Warp(character->mapid, character->x, character->y); 432 } 433 } 434 379 435 Character *World::GetCharacter(std::string name) 380 436 { -
eoserv/trunk/src/world.hpp
r171 r173 100 100 void Reboot(int seconds, std::string reason); 101 101 102 void ReloadPub(); 103 102 104 void Kick(Character *from, Character *victim, bool announce = true); 103 105 void Jail(Character *from, Character *victim, bool announce = true);
