pull/58/head
David Cernat 8 years ago
commit f562215d9a

@ -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}

@ -0,0 +1,46 @@
//
// Created by koncord on 30.08.16.
//
#include <apps/openmw-mp/Player.hpp>
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
#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);
}

@ -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

@ -10,6 +10,7 @@
#include <Script/Functions/GUI.hpp>
#include <Script/Functions/Stats.hpp>
#include <Script/Functions/Items.hpp>
#include <Script/Functions/World.hpp>
#include <RakNetTypes.h>
//#include <amx/amx.h>
#include <tuple>
@ -82,6 +83,7 @@ public:
ITEMAPI,
GUIFUNCTIONS,
CHARCLASSFUNCTIONS,
WORLDFUNCTIONS,
};

@ -587,6 +587,20 @@ void Networking::ReceiveMessage(RakNet::Packet *packet)
}
break;
}
case ID_GAME_TIME:
{
if(id == myid)
{
myPacket->Packet(&bsIn, getLocalPlayer(), false);
MWBase::World *world = MWBase::Environment::get().getWorld();
if(getLocalPlayer()->hour != -1)
world->setHour(getLocalPlayer()->hour);
else if(getLocalPlayer()->day != -1)
world->setDay(getLocalPlayer()->day);
else if(getLocalPlayer()->month != -1)
world->setMonth(getLocalPlayer()->month);
}
}
default:
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Custom message with identifier %i has arrived in initialization.", packet->data[0]);
}

@ -151,7 +151,7 @@ add_component_dir (openmw-mp
Packets/BasePacket Packets/PacketBaseInfo Packets/PacketPosition Packets/PacketEquiped Packets/PacketAttributesAndStats
Packets/PacketAttack Packets/PacketMainStats Packets/PacketCell Packets/PacketDrawState Packets/PacketChatMessage
Packets/PacketCharGen Packets/PacketAttribute Packets/PacketSkill Packets/PacketHandshake Packets/PacketGUIBoxes
Packets/PacketClass)
Packets/PacketClass Packets/PacketTime)
add_component_dir (fallback
fallback validate

@ -144,6 +144,9 @@ namespace mwmp
RakNet::RakNetGUID guid;
GUIMessageBox guiMessageBox;
ESM::Class klass;
int month;
int day;
double hour;
protected:
ESM::Position pos;

@ -32,7 +32,8 @@ enum GameMessages
ID_GAME_CHARCLASS,
ID_GAME_SKILLPRIORITY,
ID_HANDSHAKE,
ID_GUI_MESSAGEBOX
ID_GUI_MESSAGEBOX,
ID_GAME_TIME
};

@ -0,0 +1,22 @@
//
// Created by koncord on 30.08.16.
//
#include "PacketTime.hpp"
#include <components/openmw-mp/NetworkMessages.hpp>
using namespace mwmp;
PacketTime::PacketTime(RakNet::RakPeerInterface *peer) : BasePacket(peer)
{
packetID = ID_GAME_TIME;
}
void PacketTime::Packet(RakNet::BitStream *bs, BasePlayer *player, bool send)
{
BasePacket::Packet(bs, player, send);
RW(player->month, send);
RW(player->day, send);
RW(player->hour, send);
}

@ -0,0 +1,24 @@
//
// Created by koncord on 30.08.16.
//
#ifndef OPENMW_TIMEPACKET_HPP
#define OPENMW_TIMEPACKET_HPP
#include <components/openmw-mp/Packets/BasePacket.hpp>
namespace mwmp
{
class PacketTime : public BasePacket
{
public:
const static int StatsCount = 27;
PacketTime(RakNet::RakPeerInterface *peer);
virtual void Packet(RakNet::BitStream *bs, BasePlayer *player, bool send);
};
}
#endif //OPENMW_TIMEPACKET_HPP

@ -25,6 +25,7 @@
#include "Packets/PacketSkill.hpp"
#include "Packets/PacketHandshake.hpp"
#include "Packets/PacketGUIBoxes.hpp"
#include "Packets/PacketTime.hpp"
#include "PacketsController.hpp"
@ -61,6 +62,8 @@ mwmp::PacketsController::PacketsController(RakNet::RakPeerInterface *peer)
AddPacket<PacketHandshake>(&packets, peer);
AddPacket<PacketGUIBoxes>(&packets, peer);
AddPacket<PacketClass>(&packets, peer);
AddPacket<PacketTime>(&packets, peer);
}

Loading…
Cancel
Save