Exemplo n.º 1
0
static int initialize(lua_State* L) {
	RoomData* room = static_cast<RoomData*>(lua_touserdata(L, 1));

	//set the refs of these parameters (backwards, since it pops from the top of the stack)
	room->GetPager()->SetUnloadReference(luaL_ref(L, LUA_REGISTRYINDEX));
	room->GetPager()->SetCreateReference(luaL_ref(L, LUA_REGISTRYINDEX));
	room->GetPager()->SetSaveReference(luaL_ref(L, LUA_REGISTRYINDEX));
	room->GetPager()->SetLoadReference(luaL_ref(L, LUA_REGISTRYINDEX));

	//more parameters can be added here later
	return 0;
}
Exemplo n.º 2
0
void ServerApplication::hRegionRequest(RegionPacket* const argPacket) {
	//get the region object, send a rejection on error
	RoomData* room = roomMgr.Get(argPacket->roomIndex);
	if (!room) {
		//build the error message
		std::ostringstream msg;
		msg << "Failed to find Region (" << argPacket->roomIndex << "," << argPacket->x << "," << argPacket->y << "); ";
		msg << "Room " << argPacket->roomIndex << " does not exist";

		//build the packet
		TextPacket newPacket;
		newPacket.type = SerialPacketType::REGION_REJECTION;
		strncpy(newPacket.text, msg.str().c_str(), PACKET_STRING_SIZE);
		network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));

		//log the error
		std::cerr << "Error message sent: " << newPacket.text << std::endl;
		return;
	}
	Region* region = room->GetPager()->GetRegion(argPacket->x, argPacket->y);

	//send the content
	RegionPacket newPacket;

	newPacket.type = SerialPacketType::REGION_CONTENT;
	newPacket.roomIndex = argPacket->roomIndex;
	newPacket.x = argPacket->x;
	newPacket.y = argPacket->y;
	newPacket.region = region;

	network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
}
Exemplo n.º 3
0
static int getPager(lua_State* L) {
	RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
	lua_pushlightuserdata(L, reinterpret_cast<void*>(room->GetPager()) );
	return 1;
}