diff --git a/apps/openmw-mp/CMakeLists.txt b/apps/openmw-mp/CMakeLists.txt index 2d06394e8..c5313be64 100644 --- a/apps/openmw-mp/CMakeLists.txt +++ b/apps/openmw-mp/CMakeLists.txt @@ -51,7 +51,8 @@ set(SERVER Script/Script.cpp Script/ScriptFunction.cpp Script/ScriptFunctions.cpp Script/Functions/Translocations.cpp Script/Functions/Stats.cpp Script/Functions/Items.cpp - Script/Functions/Timer.cpp Script/Functions/Chat.cpp Script/Functions/GUI.cpp Script/Functions/CharClass.cpp Script/Functions/CharClass.hpp + Script/Functions/Timer.cpp Script/Functions/Chat.cpp Script/Functions/GUI.cpp + Script/Functions/CharClass.cpp Script/Functions/CharClass.hpp Script/Functions/World.cpp Script/API/TimerAPI.cpp Script/API/PublicFnAPI.cpp ${PawnScript_Sources} ${LuaScript_Sources} diff --git a/apps/openmw-mp/Script/Functions/World.cpp b/apps/openmw-mp/Script/Functions/World.cpp new file mode 100644 index 000000000..15c22592f --- /dev/null +++ b/apps/openmw-mp/Script/Functions/World.cpp @@ -0,0 +1,46 @@ +// +// Created by koncord on 30.08.16. +// + +#include +#include +#include +#include +#include "World.hpp" + +void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept +{ + Player *player; + GET_PLAYER(pid, player,); + + player->hour = hour; + player->month = -1; + player->day = -1; + + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false); +} + +void WorldFunctions::SetMonth(unsigned short pid, int month) noexcept +{ + Player *player; + GET_PLAYER(pid, player,); + + player->hour = -1; + player->month = month; + player->day = -1; + + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false); + +} + +void WorldFunctions::SetDay(unsigned short pid, int day) noexcept +{ + Player *player; + GET_PLAYER(pid, player,); + + player->hour = -1; + player->month = -1; + player->day = day; + + mwmp::Networking::Get().GetController()->GetPacket(ID_GAME_TIME)->Send(player, false); +} diff --git a/apps/openmw-mp/Script/Functions/World.hpp b/apps/openmw-mp/Script/Functions/World.hpp new file mode 100644 index 000000000..6bffb268c --- /dev/null +++ b/apps/openmw-mp/Script/Functions/World.hpp @@ -0,0 +1,22 @@ +// +// Created by koncord on 30.08.16. +// + +#ifndef OPENMW_WORLD_HPP +#define OPENMW_WORLD_HPP + +#define WORLDFUNCTIONS \ + {"SetHour", WorldFunctions::SetHour},\ + {"SetMonth", WorldFunctions::SetMonth},\ + {"SetDay", WorldFunctions::SetDay} + +class WorldFunctions +{ +public: + static void SetHour(unsigned short pid, double hour) noexcept; + static void SetMonth(unsigned short pid, int month) noexcept; + static void SetDay(unsigned short pid, int day) noexcept; +}; + + +#endif //OPENMW_WORLD_HPP diff --git a/apps/openmw-mp/Script/ScriptFunctions.hpp b/apps/openmw-mp/Script/ScriptFunctions.hpp index d120108ab..8d59b7d57 100644 --- a/apps/openmw-mp/Script/ScriptFunctions.hpp +++ b/apps/openmw-mp/Script/ScriptFunctions.hpp @@ -10,6 +10,7 @@ #include