Minor tweak to hCharacterMovement()

This commit is contained in:
Kayne Ruse
2015-03-13 19:36:03 +11:00
parent d2bb3575fc
commit 954213f1ff
3 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -59,7 +59,7 @@ createTrigger("door 1", overworld, 128, -128, function(entity)
end end
local x, y = characterAPI.GetOrigin(entity) local x, y = characterAPI.GetOrigin(entity)
characterAPI.SetRoomIndex(entity, uidTwo) --TODO: (0) take exit coordinates as a parameter characterAPI.SetRoomIndex(entity, uidTwo)
characterAPI.SetOrigin(entity, 0, 0) characterAPI.SetOrigin(entity, 0, 0)
networkAPI.PumpCharacterUpdate(entity) networkAPI.PumpCharacterUpdate(entity)
end) end)
+3 -2
View File
@@ -49,9 +49,10 @@ static int setRoomIndex(lua_State* L) { //TODO: (1) take the room userdata as a
//error checking //error checking
if (characterIndex == -1) { if (characterIndex == -1) {
throw(std::runtime_error("Failed to find character index by reference")); throw(std::runtime_error("Lua Error: Failed to find character index by reference"));
} }
//send the delete & create messages
pumpAndChangeRooms(character, lua_tointeger(L, 2), characterIndex); pumpAndChangeRooms(character, lua_tointeger(L, 2), characterIndex);
return 0; return 0;
} }
@@ -75,8 +76,8 @@ static int getAvatar(lua_State* L) {
} }
static const luaL_Reg characterLib[] = { static const luaL_Reg characterLib[] = {
// {"GetOwner", getOwner}, //unusable without account API
{"SetRoomIndex", setRoomIndex}, {"SetRoomIndex", setRoomIndex},
// {"GetOwner", getOwner}, //unusable without account API
{"GetHandle", getHandle}, {"GetHandle", getHandle},
{"GetAvatar", getAvatar}, {"GetAvatar", getAvatar},
{nullptr, nullptr} {nullptr, nullptr}
+5
View File
@@ -212,6 +212,11 @@ void ServerApplication::hCharacterMovement(CharacterPacket* const argPacket) {
//check if moving rooms //check if moving rooms
if (characterData->GetRoomIndex() != argPacket->roomIndex) { if (characterData->GetRoomIndex() != argPacket->roomIndex) {
//set the character's origin and motion
characterData->SetOrigin(argPacket->origin);
characterData->SetMotion(argPacket->motion);
//send the delete & create messages
pumpAndChangeRooms(characterData, argPacket->roomIndex, argPacket->characterIndex); pumpAndChangeRooms(characterData, argPacket->roomIndex, argPacket->characterIndex);
} }
//if not moving between rooms //if not moving between rooms