Changeset 181
- Timestamp:
- 12/31/09 04:24:55 (8 months ago)
- Location:
- eoserv/trunk
- Files:
-
- 15 modified
-
config.extra.ini (modified) (1 diff)
-
data/formulas.ini (modified) (1 diff)
-
src/character.cpp (modified) (5 diffs)
-
src/character.hpp (modified) (4 diffs)
-
src/eodata.cpp (modified) (1 diff)
-
src/eodata.hpp (modified) (2 diffs)
-
src/handlers/Board.cpp (modified) (6 diffs)
-
src/handlers/Jukebox.cpp (modified) (2 diffs)
-
src/handlers/Trade.cpp (modified) (1 diff)
-
src/handlers/Walk.cpp (modified) (1 diff)
-
src/main.cpp (modified) (1 diff)
-
src/map.cpp (modified) (5 diffs)
-
src/map.hpp (modified) (3 diffs)
-
src/world.cpp (modified) (1 diff)
-
src/world.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
eoserv/trunk/config.extra.ini
r178 r181 93 93 JukeboxPrice = 25 94 94 95 ## DoorTimer (number) 96 # How long a door remains open 97 DoorTimer = 3s 98 95 99 96 100 ## ITEM LIMITS ## -
eoserv/trunk/data/formulas.ini
r178 r181 15 15 16 16 # Hit rate and damage 17 hit_rate = 200 modifier target_evade * / 0.8 1.2 critical ? 200 accuracy / + - 0.2 max 1.0 min17 hit_rate = 100 modifier target_evade * / 0.8 1.0 critical ? 100 accuracy / + - 0.2 max 1.0 min 18 18 damage = 3 target_armor / modifier * damage - 0.1 damage * ceil max 1 1.5 critical ? * 19 19 -
eoserv/trunk/src/character.cpp
r180 r181 185 185 this->bank_npc = 0; 186 186 this->barber_npc = 0; 187 this->board = 0; 188 this->jukebox_open = false; 187 189 188 190 this->next_arena = 0; … … 215 217 this->party = 0; 216 218 this->map = this->world->GetMap(0); 217 218 this->jukebox_open = false;219 219 } 220 220 … … 662 662 this->bank_npc = 0; 663 663 this->barber_npc = 0; 664 this->jukebox_open = true; 664 this->board = 0; 665 this->jukebox_open = false; 665 666 666 667 this->warp_anim = animation; … … 781 782 } 782 783 783 void Character::ShowBoard( int boardid)784 { 785 if ( static_cast<std::size_t>(boardid) > this->world->boards.size())786 { 787 return;784 void Character::ShowBoard(Board *board) 785 { 786 if (!board) 787 { 788 board = this->board; 788 789 } 789 790 790 791 PacketBuilder builder(PACKET_BOARD, PACKET_OPEN); 791 builder.AddChar(board id);792 builder.AddChar( this->world->boards[boardid]->posts.size());792 builder.AddChar(board->id + 1); 793 builder.AddChar(board->posts.size()); 793 794 794 795 int post_count = 0; 795 796 int recent_post_count = 0; 796 797 797 UTIL_PTR_LIST_FOREACH( this->world->boards[boardid]->posts, Board_Post, post)798 UTIL_PTR_LIST_FOREACH(board->posts, Board_Post, post) 798 799 { 799 800 if (post->author == this->player->character->name) … … 810 811 int posts_remaining = std::min(static_cast<int>(this->world->config["BoardMaxUserPosts"]) - post_count, static_cast<int>(this->world->config["BoardMaxUserRecentPosts"]) - recent_post_count); 811 812 812 UTIL_PTR_LIST_FOREACH( this->world->boards[boardid]->posts, Board_Post, post)813 UTIL_PTR_LIST_FOREACH(board->posts, Board_Post, post) 813 814 { 814 815 builder.AddShort(post->id); -
eoserv/trunk/src/character.hpp
r180 r181 113 113 NPC *bank_npc; 114 114 NPC *barber_npc; 115 Board *board; 115 116 bool jukebox_open; 116 117 … … 169 170 void Warp(short map, unsigned char x, unsigned char y, WarpAnimation animation = WARP_ANIMATION_NONE); 170 171 void Refresh(); 171 void ShowBoard( int boardid);172 void ShowBoard(Board *board = 0); 172 173 std::string PaddedGuildTag(); 173 174 int Usage(); … … 257 258 SCRIPT_REGISTER_VARIABLE("NPC @", bank_npc); 258 259 SCRIPT_REGISTER_VARIABLE("NPC @", barber_npc); 260 SCRIPT_REGISTER_VARIABLE("Board @", board); 259 261 SCRIPT_REGISTER_VARIABLE("bool", jukebox_open); 260 262 SCRIPT_REGISTER_VARIABLE("WarpAnimation", warp_anim); … … 293 295 SCRIPT_REGISTER_FUNCTION("void Warp(int16 map, uint8 x, uint8 y, WarpAnimation animation)", Warp); 294 296 SCRIPT_REGISTER_FUNCTION("void Refresh()", Refresh); 295 SCRIPT_REGISTER_FUNCTION("void ShowBoard( int boardid)", ShowBoard);297 SCRIPT_REGISTER_FUNCTION("void ShowBoard(Board @)", ShowBoard); 296 298 SCRIPT_REGISTER_FUNCTION("string PaddedGuildTag()", PaddedGuildTag); 297 299 SCRIPT_REGISTER_FUNCTION("int Usage()", Usage); -
eoserv/trunk/src/eodata.cpp
r177 r181 141 141 } 142 142 143 unsigned int EIF::GetKey(int keynum) 144 { 145 int keycount = 0; 146 147 for (std::size_t i = 0; i < this->data.size(); ++i) 148 { 149 if (this->Get(i)->type == EIF::Key) 150 { 151 if (keycount == keynum) 152 { 153 return i; 154 } 155 156 ++keycount; 157 } 158 } 159 160 return 0; 161 } 162 143 163 void ENF::Read(std::string filename) 144 164 { -
eoserv/trunk/src/eodata.hpp
r180 r181 100 100 101 101 EIF_Data *Get(unsigned int id); 102 unsigned int GetKey(int keynum); 102 103 103 104 static EIF *ScriptFactory(std::string filename) { return new EIF(filename); } … … 166 167 167 168 SCRIPT_REGISTER_FUNCTION("EIF_Data @Get(uint)", Get); 169 SCRIPT_REGISTER_FUNCTION("uint GetKey(int)", GetKey); 168 170 SCRIPT_REGISTER_END() 169 171 }; -
eoserv/trunk/src/handlers/Board.cpp
r171 r181 6 6 7 7 #include "handlers.h" 8 9 #include "map.hpp" 8 10 9 11 CLIENT_F_FUNC(Board) … … 17 19 if (this->state < EOClient::Playing) return false; 18 20 19 short boardid =reader.GetShort();21 /*short boardid =*/ reader.GetShort(); 20 22 short postid = reader.GetShort(); 21 23 22 if ( static_cast<std::size_t>(boardid) > this->server->world->boards.size())24 if (this->player->character->board) 23 25 { 24 return true; 26 if (this->player->character->admin < static_cast<int>(this->server->world->admin_config["boardmod"])) 27 { 28 // Not in the official EO servers, but nice to use 29 this->player->character->ShowBoard(); 30 return true; 31 } 32 33 UTIL_PTR_LIST_FOREACH(this->player->character->board->posts, Board_Post, post) 34 { 35 if (post->id == postid) 36 { 37 if (post->author_admin < this->player->character->admin 38 || post->author == this->player->character->name) 39 { 40 this->player->character->board->posts.erase(post); 41 } 42 break; 43 } 44 } 45 46 // Not in the official EO servers, but nice to use 47 this->player->character->ShowBoard(); 25 48 } 26 27 if (this->player->character->admin < static_cast<int>(this->server->world->admin_config["boardmod"]))28 {29 // Not in the official EO servers, but nice to use30 this->player->character->ShowBoard(boardid);31 return true;32 }33 34 UTIL_PTR_LIST_FOREACH(this->server->world->boards[boardid]->posts, Board_Post, post)35 {36 if (post->id == postid)37 {38 if (post->author_admin < this->player->character->admin39 || post->author == this->player->character->name)40 {41 this->server->world->boards[boardid]->posts.erase(post);42 }43 break;44 }45 }46 47 // Not in the official EO servers, but nice to use48 this->player->character->ShowBoard(boardid);49 49 } 50 50 break; … … 54 54 if (this->state < EOClient::Playing) return false; 55 55 56 short boardid =reader.GetShort();56 /*short boardid =*/ reader.GetShort(); 57 57 reader.GetByte(); 58 58 std::string subject = reader.GetBreakString(); 59 59 std::string body = reader.GetBreakString(); 60 61 if (static_cast<std::size_t>(boardid) > this->server->world->boards.size())62 {63 return true;64 }65 60 66 61 for (std::string::iterator i = subject.begin(); i != subject.end(); ++i) … … 78 73 int recent_post_count = 0; 79 74 80 UTIL_PTR_LIST_FOREACH(this->server->world->boards[boardid]->posts, Board_Post, post)75 if (this->player->character->board) 81 76 { 82 if (post->author == this->player->character->name)77 UTIL_PTR_LIST_FOREACH(this->player->character->board->posts, Board_Post, post) 83 78 { 84 ++post_count; 79 if (post->author == this->player->character->name) 80 { 81 ++post_count; 85 82 86 if (post_count >= static_cast<int>(this->server->world->config["BoardMaxUserPosts"])) 87 { 88 // Not in the official EO servers, but nice to use 89 this->player->character->ShowBoard(boardid); 90 return true; 91 } 92 93 if (post->time + static_cast<int>(this->server->world->config["BoardRecentPostTime"]) > Timer::GetTime()) 94 { 95 ++recent_post_count; 96 97 if (recent_post_count >= static_cast<int>(this->server->world->config["BoardMaxUserRecentPosts"])) 83 if (post_count >= static_cast<int>(this->server->world->config["BoardMaxUserPosts"])) 98 84 { 99 85 // Not in the official EO servers, but nice to use 100 this->player->character->ShowBoard( boardid);86 this->player->character->ShowBoard(); 101 87 return true; 88 } 89 90 if (post->time + static_cast<int>(this->server->world->config["BoardRecentPostTime"]) > Timer::GetTime()) 91 { 92 ++recent_post_count; 93 94 if (recent_post_count >= static_cast<int>(this->server->world->config["BoardMaxUserRecentPosts"])) 95 { 96 // Not in the official EO servers, but nice to use 97 this->player->character->ShowBoard(); 98 return true; 99 } 102 100 } 103 101 } 104 102 } 103 104 Board_Post *newpost = new Board_Post; 105 newpost->id = ++this->player->character->board->last_id; 106 newpost->author = this->player->character->name; 107 newpost->author_admin = this->player->character->admin; 108 newpost->subject = subject; 109 newpost->body = body; 110 newpost->time = Timer::GetTime(); 111 112 this->player->character->board->posts.push_front(newpost); 113 114 if (this->player->character->board->posts.size() > static_cast<std::size_t>(static_cast<int>(this->server->world->config["BoardMaxPosts"]))) 115 { 116 this->player->character->board->posts.pop_back(); 117 } 118 119 // Not in the official EO servers, but nice to use 120 this->player->character->ShowBoard(); 105 121 } 106 107 Board_Post *newpost = new Board_Post;108 newpost->id = ++this->server->world->boards[boardid]->last_id;109 newpost->author = this->player->character->name;110 newpost->author_admin = this->player->character->admin;111 newpost->subject = subject;112 newpost->body = body;113 newpost->time = Timer::GetTime();114 115 this->server->world->boards[boardid]->posts.push_front(newpost);116 117 if (this->server->world->boards[boardid]->posts.size() > static_cast<std::size_t>(static_cast<int>(this->server->world->config["BoardMaxPosts"])))118 {119 this->server->world->boards[boardid]->posts.pop_back();120 }121 122 // Not in the official EO servers, but nice to use123 this->player->character->ShowBoard(boardid);124 122 } 125 123 break; … … 129 127 if (this->state < EOClient::Playing) return false; 130 128 131 short boardid =reader.GetShort();129 /*short boardid =*/ reader.GetShort(); 132 130 short postid = reader.GetShort(); 133 131 134 if ( static_cast<std::size_t>(boardid) > this->server->world->boards.size())132 if (this->player->character->board) 135 133 { 136 return true; 137 } 138 139 UTIL_PTR_LIST_FOREACH(this->server->world->boards[boardid]->posts, Board_Post, post) 140 { 141 if (post->id == postid) 134 UTIL_PTR_LIST_FOREACH(this->player->character->board->posts, Board_Post, post) 142 135 { 143 reply.SetID(PACKET_BOARD, PACKET_PLAYER); 144 reply.AddShort(postid); 145 reply.AddString(post->body); 146 CLIENT_SEND(reply); 147 break; 136 if (post->id == postid) 137 { 138 reply.SetID(PACKET_BOARD, PACKET_PLAYER); 139 reply.AddShort(postid); 140 reply.AddString(post->body); 141 CLIENT_SEND(reply); 142 break; 143 } 148 144 } 149 145 } … … 154 150 { 155 151 if (this->state < EOClient::Playing) return false; 152 CLIENT_QUEUE_ACTION(0.0) 156 153 157 154 short boardid = reader.GetShort(); 158 155 159 this->player->character->ShowBoard(boardid); 156 if (static_cast<std::size_t>(boardid) >= this->server->world->boards.size()) 157 { 158 return true; 159 } 160 161 for (std::size_t y = 0; y < this->player->character->map->height; ++y) 162 { 163 for (std::size_t x = 0; x < this->player->character->map->width; ++x) 164 { 165 if (this->player->character->InRange(x, y) 166 && this->player->character->map->GetSpec(x, y) == static_cast<Map_Tile::TileSpec>(Map_Tile::Board1 + boardid)) 167 { 168 this->player->character->board = this->server->world->boards[boardid]; 169 } 170 } 171 } 172 173 if (this->player->character->board) 174 { 175 this->player->character->ShowBoard(); 176 } 160 177 } 161 178 break; -
eoserv/trunk/src/handlers/Jukebox.cpp
r178 r181 17 17 case PACKET_OPEN: // Opened the jukebox listing 18 18 { 19 if (this->state < EOClient::Playing Modal) return false;19 if (this->state < EOClient::Playing) return false; 20 20 CLIENT_QUEUE_ACTION(0.0) 21 21 … … 45 45 case PACKET_MSG: // Requested a song 46 46 { 47 if (this->state < EOClient::Playing Modal) return false;47 if (this->state < EOClient::Playing) return false; 48 48 49 49 reader.GetChar(); -
eoserv/trunk/src/handlers/Trade.cpp
r171 r181 60 60 builder.AddBreakString(this->player->character->name); 61 61 CLIENT_SEND(builder); 62 63 builder.Reset(); 64 builder.AddShort(this->player->character->id); 65 builder.AddBreakString(this->player->character->name); 66 builder.AddShort(victim->id); 67 builder.AddBreakString(victim->name); 62 68 victim->player->client->SendBuilder(builder); 63 69 -
eoserv/trunk/src/handlers/Walk.cpp
r178 r181 53 53 this->player->character->bank_npc = 0; 54 54 this->player->character->barber_npc = 0; 55 this->player->character->jukebox_open = true; 55 this->player->character->board = 0; 56 this->player->character->jukebox_open = false; 56 57 if (!this->player->character->Walk(direction)) 57 58 { -
eoserv/trunk/src/main.cpp
r179 r181 377 377 eoserv_config_default(config, "JukeboxPrice" , 25); 378 378 eoserv_config_default(config, "JukeboxTimer" , 90); 379 eoserv_config_default(config, "DoorTimer" , 3.0); 379 380 eoserv_config_default(config, "MaxBankGold" , 2000000000); 380 381 eoserv_config_default(config, "MaxItem" , 10000000); -
eoserv/trunk/src/map.cpp
r178 r181 89 89 } 90 90 } 91 } 92 93 struct map_close_door_struct : public Shared 94 { 95 Map *map; 96 unsigned char x, y; 97 }; 98 99 void map_close_door(void *map_close_door_struct_void) 100 { 101 map_close_door_struct *close(static_cast<map_close_door_struct *>(map_close_door_struct_void)); 102 103 close->map->CloseDoor(close->x, close->y); 104 105 close->Release(); 91 106 } 92 107 … … 728 743 if (!admin && (warp = this->GetWarp(target_x, target_y))) 729 744 { 730 if (from->level >= warp->levelreq )745 if (from->level >= warp->levelreq && (warp->spec == Map_Warp::NoDoor || warp->open)) 731 746 { 732 747 from->Warp(warp->map, warp->x, warp->y); … … 1282 1297 double hit_rate = rpn_eval(rpn_parse(this->world->formulas_config["hit_rate"]), formula_vars); 1283 1298 1284 printf("damage %i / %g > %g", amount, rand, hit_rate);1285 1286 1299 if (rand > hit_rate) 1287 1300 { … … 1570 1583 if (Map_Warp *warp = this->GetWarp(x, y)) 1571 1584 { 1572 if (warp->spec == Map_Warp::NoDoor /* || warp->open*/)1585 if (warp->spec == Map_Warp::NoDoor || warp->open) 1573 1586 { 1574 1587 return false; 1575 1588 } 1576 1589 1577 // TODO: Check for keys 1578 // TODO: Check for open/closed doors 1590 if (from && warp->spec > Map_Warp::Door) 1591 { 1592 if (!from->HasItem(this->world->eif->GetKey(warp->spec - static_cast<int>(Map_Warp::Door)))) 1593 { 1594 return false; 1595 } 1596 } 1579 1597 1580 1598 PacketBuilder builder; … … 1591 1609 } 1592 1610 1593 /*warp->open = true;*/ 1611 warp->open = true; 1612 1613 map_close_door_struct *close = new map_close_door_struct; 1614 close->map = this; 1615 close->x = x; 1616 close->y = y; 1617 1618 TimeEvent *event = new TimeEvent(map_close_door, close, this->world->config["DoorTimer"], 1); // TODO: Make this a config variable 1619 this->world->timer.Register(event); 1620 event->Release(); 1621 1594 1622 return true; 1595 1623 } 1596 1624 1597 1625 return false; 1626 } 1627 1628 void Map::CloseDoor(unsigned char x, unsigned char y) 1629 { 1630 if (Map_Warp *warp = this->GetWarp(x, y)) 1631 { 1632 if (warp->spec == Map_Warp::NoDoor || !warp->open) 1633 { 1634 return; 1635 } 1636 1637 warp->open = false; 1638 } 1598 1639 } 1599 1640 -
eoserv/trunk/src/map.hpp
r175 r181 163 163 case Board6: 164 164 case Board7: 165 case Board8: 165 166 case Jukebox: 166 167 return false; … … 339 340 void Emote(Character *from, enum Emote emote, bool echo = true); 340 341 bool OpenDoor(Character *from, unsigned char x, unsigned char y); 342 void CloseDoor(unsigned char x, unsigned char y); 341 343 342 344 bool Walk(NPC *from, Direction direction); … … 414 416 SCRIPT_REGISTER_FUNCTION("void Emote(Character @from, Emote emote, bool echo)", Emote); 415 417 SCRIPT_REGISTER_FUNCTION("bool OpenDoor(Character @from, uint8 x, uint8 y)", OpenDoor); 418 SCRIPT_REGISTER_FUNCTION("void CloseDoor(uint8 x, uint8 y)", CloseDoor); 416 419 SCRIPT_REGISTER_FUNCTION_PR("bool Walk(NPC @from, Direction direction)", Walk, (NPC *, Direction), bool); 417 420 SCRIPT_REGISTER_FUNCTION("Map_Item @AddItem(int16 id, int amount, uint8 x, uint8 y, Character @from)", AddItem); -
eoserv/trunk/src/world.cpp
r177 r181 223 223 for (std::size_t i = 0; i < this->boards.size(); ++i) 224 224 { 225 this->boards[i] = new Board ;225 this->boards[i] = new Board(i); 226 226 } 227 227 -
eoserv/trunk/src/world.hpp
r177 r181 36 36 struct Board : public Shared 37 37 { 38 int id; 38 39 short last_id; 39 40 PtrList<Board_Post> posts; 40 41 41 Board( ) :last_id(0) { }42 Board(int id_) : id(id_), last_id(0) { } 42 43 43 SCRIPT_REGISTER_REF_DF(Board) 44 static Board *ScriptFactory(int id) { return new Board(id); } 45 46 SCRIPT_REGISTER_REF(Board) 47 SCRIPT_REGISTER_FACTORY("Board @f(int id)", ScriptFactory); 48 44 49 SCRIPT_REGISTER_VARIABLE("int16", last_id); 45 50 SCRIPT_REGISTER_VARIABLE("PtrList<Board_Post>", posts);
