Skip to content

Commit

Permalink
Merge pull request #92 from serg-bloim/feature/map_rotation
Browse files Browse the repository at this point in the history
Implements stop the server after the last map.
  • Loading branch information
igroglaz authored Nov 25, 2020
2 parents b7c96dd + bb73b85 commit dba05ab
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config_new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace Config

float mage_pvp_dmg_factor = 1;
float shop_potions_factor = 1;
bool server_rotate_maps = true;
}

int32_t ReadIntegerParameter(std::string value, int32_t MinValue, int32_t MaxValue)
Expand Down Expand Up @@ -319,6 +319,11 @@ int ReadConfig(const char* filename)
if(!CheckFloat(value)) return lnid;
Config::shop_potions_factor = ReadFloatParameter(value,0,100);
}
else if(parameter == ToLower("ServerRotateMaps"))
{
if(!CheckBool(value)) return lnid;
Config::server_rotate_maps = StrToBool(value);
}
else if(parameter == "description")
{
SetCString((byte*)(0x006D15C0), value.c_str());
Expand Down
1 change: 1 addition & 0 deletions config_new.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ namespace Config
extern uint32_t QuestRollInterval;
extern float mage_pvp_dmg_factor;
extern float shop_potions_factor;
extern bool server_rotate_maps;
}

int ReadConfig(const char* filename);
1 change: 1 addition & 0 deletions configs/server.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ WearDropProbability = 0.11
QuestRollInterval = 1
MagePvpDmgFactor = 1.3
ShopPotionsFactor = 2
ServerRotateMaps = true // true - repeat maps, false - stop server after the last map

WarriorMaleMaxBody = 43
WarriorMaleMaxReaction = 58
Expand Down
29 changes: 29 additions & 0 deletions map_rotation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "config_new.h"
#include <stdlib.h>
#include "lib\utils.hpp"

void stop_server()
{
exit(0);
}

void __stdcall reset_map_counter()
{
if(Config::server_rotate_maps){
Printf("Rolling maps");
int *server_map_index = (int *)(void *)0x006D1634;
*server_map_index = 0;
}else{
Printf("Stopping server after the last map");
stop_server();
}
}

int __declspec(naked) imp_reset_map_counter()
{
__asm{
mov edx, reset_map_counter
call edx
ret
}
}
2 changes: 2 additions & 0 deletions postbuild/server.dis
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ CALL imp_increase_potions_in_shops 0054DAFC // increase number of potions in sh

CALL imp_inn_item_upgrade_failed 0056154E 149 // handles a situation when player upgrades an item in the inn, but does not have the original item on. 149 NOPs to override till 005615E9

CAll imp_reset_map_counter 0048AB79 4 // checks if it needs to exit after the last map

JMP set_warrior_male_max_parameters 531650 // set_warrior_male_max_parameters
JMP set_warrior_female_max_parameters 53166C // set_warrior_female_max_parameters
JMP set_mage_male_max_parameters 531696 // set_mage_male_max_parameters
Expand Down
1 change: 1 addition & 0 deletions srvmgr.def
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ imp_regen @207
imp_distance_bug_fix @208
imp_increase_potions_in_shops @209
imp_inn_item_upgrade_failed @210
imp_reset_map_counter @211
set_warrior_male_max_parameters @301
set_warrior_female_max_parameters @302
set_mage_male_max_parameters @303
Expand Down
1 change: 1 addition & 0 deletions srvmgr.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
<ClCompile Include="File.cpp" />
<ClCompile Include="forbidden_items.cpp" />
<ClCompile Include="itemex.cpp" />
<ClCompile Include="map_rotation.cpp" />
<ClCompile Include="multiplayer_shop.cpp" />
<ClCompile Include="partial_drop.cpp" />
<ClCompile Include="pktmgr.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions srvmgr.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@
<ClCompile Include="shops.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="map_rotation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="charcheck.h">
Expand Down

0 comments on commit dba05ab

Please sign in to comment.