PumpCharacterUpdate() works from lua to client, read more
There was a bug in the entity API, where getMotion() was pushing the origin instead of the motion. This has been corrected. Since this is an important bug, and because the features for this leg is finished, I'll merge this to master.
This commit is contained in:
@@ -56,8 +56,8 @@ static int getOrigin(lua_State* L) {
|
||||
|
||||
static int getMotion(lua_State* L) {
|
||||
Entity* entity = static_cast<Entity*>(lua_touserdata(L, 1));
|
||||
lua_pushnumber(L, entity->GetOrigin().x);
|
||||
lua_pushnumber(L, entity->GetOrigin().y);
|
||||
lua_pushnumber(L, entity->GetMotion().x);
|
||||
lua_pushnumber(L, entity->GetMotion().y);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
+38
-1
@@ -21,8 +21,45 @@
|
||||
*/
|
||||
#include "network_api.hpp"
|
||||
|
||||
#include "character_data.hpp"
|
||||
#include "character_manager.hpp"
|
||||
#include "server_utilities.hpp"
|
||||
|
||||
static int pumpCharacterUpdate(lua_State* L) {
|
||||
return 0;
|
||||
CharacterData* characterData = static_cast<CharacterData*>(lua_touserdata(L, 1));
|
||||
|
||||
//determine the character's index
|
||||
int index = -1;
|
||||
for (auto const& it : *CharacterManager::GetSingleton().GetContainer()) {
|
||||
if(characterData == &it.second) {
|
||||
index = it.first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//signal an error
|
||||
if (index == -1) {
|
||||
lua_pushboolean(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//fill the packet with all of this character's data
|
||||
CharacterPacket newPacket;
|
||||
newPacket.type = SerialPacketType::CHARACTER_UPDATE;
|
||||
newPacket.characterIndex = index;
|
||||
strncpy(newPacket.handle, characterData->GetHandle().c_str(), PACKET_STRING_SIZE);
|
||||
strncpy(newPacket.avatar, characterData->GetAvatar().c_str(), PACKET_STRING_SIZE);
|
||||
newPacket.accountIndex = characterData->GetOwner();
|
||||
newPacket.roomIndex = characterData->GetRoomIndex();
|
||||
newPacket.origin = characterData->GetOrigin();
|
||||
newPacket.motion = characterData->GetMotion();
|
||||
|
||||
//pump to the room
|
||||
pumpPacketProximity(&newPacket, characterData->GetRoomIndex());
|
||||
|
||||
//signal success
|
||||
lua_pushboolean(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg networkLib[] = {
|
||||
|
||||
@@ -183,10 +183,15 @@ void ServerApplication::hCharacterUnload(CharacterPacket* const argPacket) {
|
||||
void ServerApplication::hCharacterMovement(CharacterPacket* const argPacket) {
|
||||
//get the specified objects
|
||||
AccountData* accountData = accountMgr.Get(argPacket->accountIndex);
|
||||
|
||||
if (!accountData) {
|
||||
throw(std::runtime_error("Failed to move a character, missing account"));
|
||||
}
|
||||
|
||||
CharacterData* characterData = characterMgr.Get(argPacket->characterIndex);
|
||||
|
||||
if (!accountData || !characterData) {
|
||||
throw(std::runtime_error("Failed to move a character, missing data"));
|
||||
if (!characterData) {
|
||||
throw(std::runtime_error("Failed to move a character, missing character"));
|
||||
}
|
||||
|
||||
//get this account's client
|
||||
|
||||
Reference in New Issue
Block a user