Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 48bec25336 | |||
| 39f03b2da8 | |||
| 9a5c447d0c | |||
| 29ccb982e6 |
@@ -9,9 +9,6 @@
|
|||||||
Release/
|
Release/
|
||||||
Debug/
|
Debug/
|
||||||
Out/
|
Out/
|
||||||
release/
|
|
||||||
debug/
|
|
||||||
out/
|
|
||||||
|
|
||||||
#Project generated files
|
#Project generated files
|
||||||
*.db
|
*.db
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
## Outline
|
## Outline
|
||||||
|
|
||||||
Tortuga is a 2D MMORPG featuring permadeath, with an emphasis on multiplayer cooperation, exploration and customization. The game runs on customizable public and private servers.
|
Tortuga is a 2D multiplayer JRPG featuring permadeath, with an emphasis on multiplayer cooperation, exploration and customization. The game runs on customizable public and private servers.
|
||||||
|
|
||||||
This game is inspired by classic 2D RPGs (Final Fantasy, The Legend of Zelda), as well as more modern sandboxes and MMOs (Minecraft, EVE Online). This project is currently independently created and funded, with the goal of creating a game that will engage the players and inspire a large community.
|
This game is inspired by classic 2D RPGs (Final Fantasy, The Legend of Zelda), as well as more modern sandboxes amd MMOs (Minecraft, EVE Online). This project is currently independently created and funded, with the goal of creating a game that will engage the players and inspire a large community.
|
||||||
|
|
||||||
## Releases
|
## Releases
|
||||||
|
|
||||||
* The most recent stable build for Windows can be found [here](https://dl.dropboxusercontent.com/u/46669050/Tortuga-win.rar).
|
The most recent stable build for Windows can be found [here](https://dl.dropboxusercontent.com/u/46669050/Tortuga.rar).
|
||||||
* The most recent stable build for Linux can be found [here](https://dl.dropboxusercontent.com/u/46669050/Tortuga-linux.tar).
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@@ -17,14 +16,13 @@ This game is inspired by classic 2D RPGs (Final Fantasy, The Legend of Zelda), a
|
|||||||
## External Dependencies
|
## External Dependencies
|
||||||
|
|
||||||
* [SDL 1.2](http://www.libsdl.org/) - Simple DirectMedia Layer API
|
* [SDL 1.2](http://www.libsdl.org/) - Simple DirectMedia Layer API
|
||||||
* [SDL_net 2.0](http://www.libsdl.org/projects/SDL_net/) - SDL's networking extension
|
* [SDL_net 1.2](http://www.libsdl.org/projects/SDL_net/) - SDL's networking extension
|
||||||
* [lua 5.2](http://www.lua.org/) - The lua programming language
|
* [lua 5.2](http://www.lua.org/) - The lua programming language
|
||||||
* [SQLite3](http://www.sqlite.org/) - A lightweight SQL database engine
|
* [SQLite3](http://www.sqlite.org/) - A lightweight SQL database engine
|
||||||
|
|
||||||
## Tools
|
## Tools
|
||||||
|
|
||||||
* [WinRAR](http://www.rarlab.com/) - The best compression tool available IMO; only needed for Windows distribution
|
* [WinRAR](http://www.rarlab.com/) - The best compression tool available IMO; only needed for distribution
|
||||||
* [Dropbox](https://www.dropbox.com/) - For hosting and distribution
|
|
||||||
|
|
||||||
## Copyright
|
## Copyright
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//Scene headers
|
//Scene headers
|
||||||
@@ -58,9 +57,7 @@ void ClientApplication::Init(int argc, char* argv[]) {
|
|||||||
|
|
||||||
//initialize SDL
|
//initialize SDL
|
||||||
if (SDL_Init(SDL_INIT_VIDEO)) {
|
if (SDL_Init(SDL_INIT_VIDEO)) {
|
||||||
std::ostringstream os;
|
throw(std::runtime_error("Failed to initialize SDL"));
|
||||||
os << "Failed to initialize SDL: " << SDL_GetError();
|
|
||||||
throw(std::runtime_error(os.str()));
|
|
||||||
}
|
}
|
||||||
std::cout << "Initialized SDL" << std::endl;
|
std::cout << "Initialized SDL" << std::endl;
|
||||||
|
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
#include "channels.hpp"
|
#include "channels.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|||||||
@@ -22,12 +22,11 @@
|
|||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
#include "channels.hpp"
|
#include "channels.hpp"
|
||||||
#include "terminal_error.hpp"
|
|
||||||
|
|
||||||
|
#include "terminal_error.hpp"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -126,16 +125,8 @@ void World::Update() {
|
|||||||
it.second.Update();
|
it.second.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
//update the map
|
||||||
//update the map
|
UpdateMap();
|
||||||
UpdateMap();
|
|
||||||
}
|
|
||||||
catch(terminal_error& e) {
|
|
||||||
throw(e);
|
|
||||||
}
|
|
||||||
catch(std::exception& e) {
|
|
||||||
std::cerr << "UpdateMap Error: " << e.what() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
//skip the rest without a local character
|
//skip the rest without a local character
|
||||||
if (!localCharacter) {
|
if (!localCharacter) {
|
||||||
@@ -171,11 +162,6 @@ void World::Render(SDL_Surface* const screen) {
|
|||||||
//draw the map
|
//draw the map
|
||||||
for (std::list<Region>::iterator it = regionPager.GetContainer()->begin(); it != regionPager.GetContainer()->end(); it++) {
|
for (std::list<Region>::iterator it = regionPager.GetContainer()->begin(); it != regionPager.GetContainer()->end(); it++) {
|
||||||
tileSheet.DrawRegionTo(screen, &(*it), camera.x, camera.y);
|
tileSheet.DrawRegionTo(screen, &(*it), camera.x, camera.y);
|
||||||
|
|
||||||
//debugging
|
|
||||||
// std::ostringstream msg;
|
|
||||||
// msg << it->GetX() << ", " << it->GetY();
|
|
||||||
// font.DrawStringTo(msg.str(), screen, it->GetX() * tileSheet.GetImage()->GetClipW() - camera.x, it->GetY() * tileSheet.GetImage()->GetClipH() - camera.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw the entities
|
//draw the entities
|
||||||
|
|||||||
@@ -23,24 +23,6 @@
|
|||||||
|
|
||||||
#include "channels.hpp"
|
#include "channels.hpp"
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
|
|
||||||
//-------------------------
|
|
||||||
//static functions
|
|
||||||
//-------------------------
|
|
||||||
|
|
||||||
static int regionChecksum(Region* const region) {
|
|
||||||
int sum = 0;
|
|
||||||
for(int i = 0; i < REGION_WIDTH; i++) {
|
|
||||||
for (int j = 0; j < REGION_HEIGHT; j++) {
|
|
||||||
for (int k = 0; k < REGION_DEPTH; k++) {
|
|
||||||
sum += region->GetTile(i, j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//map management
|
//map management
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -58,13 +40,6 @@ void World::SendRegionRequest(int roomIndex, int x, int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void World::hRegionContent(RegionPacket* const argPacket) {
|
void World::hRegionContent(RegionPacket* const argPacket) {
|
||||||
//checksum
|
|
||||||
if (regionChecksum(argPacket->region) == 0) {
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "Received region checksum failed: " << argPacket->x << ", " << argPacket->y;
|
|
||||||
throw(std::runtime_error(msg.str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//replace existing regions
|
//replace existing regions
|
||||||
regionPager.UnloadIf([&](Region const& region) -> bool {
|
regionPager.UnloadIf([&](Region const& region) -> bool {
|
||||||
return region.GetX() == argPacket->x && region.GetY() == argPacket->y;
|
return region.GetX() == argPacket->x && region.GetY() == argPacket->y;
|
||||||
@@ -96,23 +71,9 @@ void World::UpdateMap() {
|
|||||||
//request empty regions within this zone
|
//request empty regions within this zone
|
||||||
for (int i = xStart; i <= xEnd; i += REGION_WIDTH) {
|
for (int i = xStart; i <= xEnd; i += REGION_WIDTH) {
|
||||||
for (int j = yStart; j <= yEnd; j += REGION_HEIGHT) {
|
for (int j = yStart; j <= yEnd; j += REGION_HEIGHT) {
|
||||||
Region* region = regionPager.FindRegion(i, j);
|
if (!regionPager.FindRegion(i, j)) {
|
||||||
if (!region) {
|
|
||||||
//request absent region
|
|
||||||
SendRegionRequest(roomIndex, i, j);
|
SendRegionRequest(roomIndex, i, j);
|
||||||
}
|
}
|
||||||
else if (regionChecksum(region) == 0) {
|
|
||||||
//checksum failed
|
|
||||||
//NOTE: this patches bug #45, but does not resolve it
|
|
||||||
regionPager.UnloadIf([region](Region const& ref) -> bool {
|
|
||||||
//remove the erroneous region
|
|
||||||
return region == &ref;
|
|
||||||
});
|
|
||||||
SendRegionRequest(roomIndex, i, j);
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "Existing region checksum failed: " << roomIndex << ", " << i << ", " << j;
|
|
||||||
throw(std::runtime_error(msg.str()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-7
@@ -1,5 +1,5 @@
|
|||||||
#include directories
|
#include directories
|
||||||
INCLUDES+=SDL . client_utilities entities gameplay_scenes menu_scenes ../common/debugging ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet_types ../common/ui ../common/utilities
|
INCLUDES+=. client_utilities entities gameplay_scenes menu_scenes ../common/debugging ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet_types ../common/ui ../common/utilities
|
||||||
|
|
||||||
#libraries
|
#libraries
|
||||||
#the order of the $(LIBS) is important, at least for MinGW
|
#the order of the $(LIBS) is important, at least for MinGW
|
||||||
@@ -45,12 +45,6 @@ $(OBJDIR)/%.o: %.cpp
|
|||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
$(RM) *.o *.a *.exe
|
$(RM) *.o *.a *.exe
|
||||||
else ifeq ($(shell uname), Linux)
|
|
||||||
find . -type f -name *.o -exec rm -f -r -v {} \;
|
|
||||||
find . -type f -name *.a -exec rm -f -r -v {} \;
|
|
||||||
rm -f -v out/client out/server
|
|
||||||
endif
|
|
||||||
|
|
||||||
rebuild: clean all
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -6,3 +6,8 @@ all:
|
|||||||
$(MAKE) -C network
|
$(MAKE) -C network
|
||||||
$(MAKE) -C ui
|
$(MAKE) -C ui
|
||||||
$(MAKE) -C utilities
|
$(MAKE) -C utilities
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ Region* RegionPagerBase::FindRegion(int x, int y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Region* RegionPagerBase::PushRegion(Region* const ptr) {
|
Region* RegionPagerBase::PushRegion(Region* const ptr) {
|
||||||
//BUG: #45 Some regions are occasionally losing their tile data
|
|
||||||
regionList.push_front(*ptr);
|
regionList.push_front(*ptr);
|
||||||
return ®ionList.front();
|
return ®ionList.front();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,3 +31,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "serial_packet_type.hpp"
|
#include "serial_packet_type.hpp"
|
||||||
|
|
||||||
#include "SDL_net.h"
|
#include "SDL/SDL_net.h"
|
||||||
|
|
||||||
constexpr int PACKET_STRING_SIZE = 100;
|
constexpr int PACKET_STRING_SIZE = 100;
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "singleton.hpp"
|
#include "singleton.hpp"
|
||||||
|
|
||||||
//APIs
|
//APIs
|
||||||
#include "SDL_net.h"
|
#include "SDL/SDL_net.h"
|
||||||
|
|
||||||
class UDPNetworkUtility : public Singleton<UDPNetworkUtility> {
|
class UDPNetworkUtility : public Singleton<UDPNetworkUtility> {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#ifndef IPOPERATORS_HPP_
|
#ifndef IPOPERATORS_HPP_
|
||||||
#define IPOPERATORS_HPP_
|
#define IPOPERATORS_HPP_
|
||||||
|
|
||||||
#include "SDL_net.h"
|
#include "SDL/SDL_net.h"
|
||||||
|
|
||||||
//these should've come standard
|
//these should've come standard
|
||||||
bool operator==(IPaddress lhs, IPaddress rhs);
|
bool operator==(IPaddress lhs, IPaddress rhs);
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -19,23 +19,13 @@ release: clean all package
|
|||||||
|
|
||||||
#For use on my machine ONLY
|
#For use on my machine ONLY
|
||||||
package:
|
package:
|
||||||
ifeq ($(OS),Windows_NT)
|
rar a -r -ep Tortuga.rar $(OUTDIR)/*.exe $(OUTDIR)/*.dll
|
||||||
rar a -r -ep Tortuga-win.rar $(OUTDIR)/*.exe $(OUTDIR)/*.dll
|
rar a -r Tortuga.rar rsc/* copyright.txt instructions.txt
|
||||||
rar a -r Tortuga-win.rar rsc/* copyright.txt instructions.txt
|
|
||||||
else ifeq ($(shell uname), Linux)
|
|
||||||
tar -C $(OUTDIR) -zcvf Tortuga-linux.tar client server ../rsc ../copyright.txt ../instructions.txt
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(OUTDIR):
|
$(OUTDIR):
|
||||||
mkdir $(OUTDIR)
|
mkdir $(OUTDIR)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
$(RM) *.o *.a *.exe
|
$(RM) *.o *.a *.exe
|
||||||
else ifeq ($(shell uname), Linux)
|
|
||||||
find . -type f -name *.o -exec rm -f -r -v {} \;
|
|
||||||
find . -type f -name *.a -exec rm -f -r -v {} \;
|
|
||||||
rm -f -v out/client out/server
|
|
||||||
endif
|
|
||||||
|
|
||||||
rebuild: clean all
|
rebuild: clean all
|
||||||
|
|||||||
@@ -1,29 +1,3 @@
|
|||||||
--[[
|
|
||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
--]]
|
|
||||||
|
|
||||||
--DOCS: a placeholder door utility
|
|
||||||
|
|
||||||
local doorUtility = {}
|
local doorUtility = {}
|
||||||
|
|
||||||
roomAPI = require("room")
|
roomAPI = require("room")
|
||||||
|
|||||||
@@ -1,29 +1,3 @@
|
|||||||
--[[
|
|
||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
--]]
|
|
||||||
|
|
||||||
--DOCS: a placeholder map generator
|
|
||||||
|
|
||||||
local regionAPI = require("region")
|
local regionAPI = require("region")
|
||||||
|
|
||||||
local mapMaker = {}
|
local mapMaker = {}
|
||||||
@@ -91,9 +65,6 @@ end
|
|||||||
|
|
||||||
--custom generation systems here
|
--custom generation systems here
|
||||||
function mapMaker.DebugIsland(r)
|
function mapMaker.DebugIsland(r)
|
||||||
--debug
|
|
||||||
io.write("map_maker:DebugIsland(", regionAPI.GetX(r), ", ", regionAPI.GetY(r), ")\n")
|
|
||||||
|
|
||||||
--basic distance check for each tile, placing an island around the world origin
|
--basic distance check for each tile, placing an island around the world origin
|
||||||
for i = 1, regionAPI.GetWidth(r) do
|
for i = 1, regionAPI.GetWidth(r) do
|
||||||
for j = 1, regionAPI.GetHeight(r) do
|
for j = 1, regionAPI.GetHeight(r) do
|
||||||
@@ -124,9 +95,6 @@ function mapMaker.DebugIsland(r)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mapMaker.DebugGrassland(r)
|
function mapMaker.DebugGrassland(r)
|
||||||
--debug
|
|
||||||
io.write("map_maker:DebugGrassland(", regionAPI.GetX(r), ", ", regionAPI.GetY(r), ")\n")
|
|
||||||
|
|
||||||
--all dirt
|
--all dirt
|
||||||
for i = 1, regionAPI.GetWidth(r) do
|
for i = 1, regionAPI.GetWidth(r) do
|
||||||
for j = 1, regionAPI.GetHeight(r) do
|
for j = 1, regionAPI.GetHeight(r) do
|
||||||
|
|||||||
@@ -1,38 +1,14 @@
|
|||||||
--[[
|
|
||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
--]]
|
|
||||||
|
|
||||||
local region = require("region")
|
local region = require("region")
|
||||||
|
|
||||||
local mapSaver = {}
|
local mapSaver = {}
|
||||||
|
|
||||||
function mapSaver.Load(r)
|
function mapSaver.Load(r)
|
||||||
--empty
|
--empty
|
||||||
-- io.write("map_saver:Load(", region.GetX(r), ", ", region.GetY(r), ")\n")
|
io.write("map_saver:Load(", region.GetX(r), ", ", region.GetY(r), ")\n")
|
||||||
end
|
end
|
||||||
function mapSaver.Save(r)
|
function mapSaver.Save(r)
|
||||||
--empty
|
--empty
|
||||||
-- io.write("map_saver:Save(", region.GetX(r), ", ", region.GetY(r), ")\n")
|
io.write("map_saver:Save(", region.GetX(r), ", ", region.GetY(r), ")\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
--TODO: (3) create a flexible saving & loading system
|
--TODO: (3) create a flexible saving & loading system
|
||||||
|
|||||||
@@ -1,29 +1,3 @@
|
|||||||
--[[
|
|
||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
--]]
|
|
||||||
|
|
||||||
--DOCS: This script is run by the server on startup
|
|
||||||
|
|
||||||
print("Lua script check")
|
print("Lua script check")
|
||||||
|
|
||||||
--requirements
|
--requirements
|
||||||
@@ -53,9 +27,10 @@ end)
|
|||||||
--NOTE: room 0 is the first that the client asks for, therefore it must exist
|
--NOTE: room 0 is the first that the client asks for, therefore it must exist
|
||||||
local overworld, uidOne = roomManagerAPI.CreateRoom("overworld", "overworld.bmp")
|
local overworld, uidOne = roomManagerAPI.CreateRoom("overworld", "overworld.bmp")
|
||||||
roomAPI.Initialize(overworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugIsland, mapSaver.Save)
|
roomAPI.Initialize(overworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugIsland, mapSaver.Save)
|
||||||
|
|
||||||
local underworld, uidTwo = roomManagerAPI.CreateRoom("underworld", "overworld.bmp")
|
local underworld, uidTwo = roomManagerAPI.CreateRoom("underworld", "overworld.bmp")
|
||||||
roomAPI.Initialize(underworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugGrassland, mapSaver.Save)
|
roomAPI.Initialize(underworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugGrassland, mapSaver.Save)
|
||||||
|
|
||||||
--call the monstrosity
|
--call the monstrosity
|
||||||
doorUtility.createDoorPair("pair 1", overworld, -64, -64, underworld, 64, 64)
|
doorUtility.createDoorPair("pair 1", overworld, 0, -64, underworld, 0, 0)
|
||||||
|
|
||||||
|
print("Finished the lua script")
|
||||||
|
|||||||
@@ -1,26 +1,6 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013-2015
|
--TODO: (3) An archive table of all dead characters
|
||||||
*
|
|
||||||
* This software is provided 'as-is', without any express or implied
|
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
|
||||||
* arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
|
||||||
* including commercial applications, and to alter it and redistribute it
|
|
||||||
* freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
|
||||||
* claim that you wrote the original software. If you use this software
|
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
|
||||||
* appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
|
||||||
* misrepresented as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source
|
|
||||||
* distribution.
|
|
||||||
*/
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS UserAccounts (
|
CREATE TABLE IF NOT EXISTS Accounts (
|
||||||
uid INTEGER PRIMARY KEY AUTOINCREMENT,
|
uid INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
username varchar(100) UNIQUE, --TODO: (3) Swap username for email address
|
username varchar(100) UNIQUE, --TODO: (3) Swap username for email address
|
||||||
|
|
||||||
@@ -35,7 +15,7 @@ CREATE TABLE IF NOT EXISTS UserAccounts (
|
|||||||
admin BIT DEFAULT 0
|
admin BIT DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS LiveCharacters (
|
CREATE TABLE IF NOT EXISTS Characters (
|
||||||
uid INTEGER PRIMARY KEY AUTOINCREMENT,
|
uid INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
--metadata
|
--metadata
|
||||||
@@ -51,45 +31,16 @@ CREATE TABLE IF NOT EXISTS LiveCharacters (
|
|||||||
boundsX INTEGER DEFAULT 0,
|
boundsX INTEGER DEFAULT 0,
|
||||||
boundsY INTEGER DEFAULT 0,
|
boundsY INTEGER DEFAULT 0,
|
||||||
boundsW INTEGER DEFAULT 0,
|
boundsW INTEGER DEFAULT 0,
|
||||||
boundsH INTEGER DEFAULT 0
|
boundsH INTEGER DEFAULT 0,
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DeadCharacters (
|
--statistics
|
||||||
uid INTEGER PRIMARY KEY,
|
baseStats INTEGER REFERENCES StatisticSets(uid),
|
||||||
|
|
||||||
--metadata
|
--equipment
|
||||||
owner INTEGER REFERENCES Accounts(uid),
|
weapon INTEGER REFERENCES WornEquipment(uid),
|
||||||
handle varchar(100),
|
helmet INTEGER REFERENCES WornEquipment(uid),
|
||||||
avatar varchar(100),
|
armour INTEGER REFERENCES WornEquipment(uid)
|
||||||
birth timestamp NOT NULL
|
--etc.
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS LiveMonsters (
|
|
||||||
uid INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
|
|
||||||
--metadata
|
|
||||||
handle varchar(100) UNIQUE,
|
|
||||||
avatar varchar(100),
|
|
||||||
|
|
||||||
--actions
|
|
||||||
-- script
|
|
||||||
|
|
||||||
--physically exists in the world
|
|
||||||
roomIndex INTEGER DEFAULT 0,
|
|
||||||
originX INTEGER DEFAULT 0,
|
|
||||||
originY INTEGER DEFAULT 0,
|
|
||||||
boundsX INTEGER DEFAULT 0,
|
|
||||||
boundsY INTEGER DEFAULT 0,
|
|
||||||
boundsW INTEGER DEFAULT 0,
|
|
||||||
boundsH INTEGER DEFAULT 0
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS DeadMonsters (
|
|
||||||
uid INTEGER PRIMARY KEY,
|
|
||||||
|
|
||||||
--metadata
|
|
||||||
handle varchar(100) UNIQUE,
|
|
||||||
avatar varchar(100)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
//Define the queries
|
//Define the queries
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
static const char* CREATE_USER_ACCOUNT = "INSERT INTO UserAccounts (username) VALUES (?);";
|
static const char* CREATE_USER_ACCOUNT = "INSERT INTO Accounts (username) VALUES (?);";
|
||||||
|
|
||||||
static const char* LOAD_USER_ACCOUNT = "SELECT "
|
static const char* LOAD_USER_ACCOUNT = "SELECT "
|
||||||
"uid, "
|
"uid, "
|
||||||
@@ -35,18 +35,18 @@ static const char* LOAD_USER_ACCOUNT = "SELECT "
|
|||||||
"whitelisted, "
|
"whitelisted, "
|
||||||
"mod, "
|
"mod, "
|
||||||
"admin "
|
"admin "
|
||||||
" FROM UserAccounts WHERE username = ?;";
|
" FROM Accounts WHERE username = ?;";
|
||||||
|
|
||||||
static const char* SAVE_USER_ACCOUNT = "UPDATE OR FAIL UserAccounts SET "
|
static const char* SAVE_USER_ACCOUNT = "UPDATE OR FAIL Accounts SET "
|
||||||
"blacklisted = ?2, "
|
"blacklisted = ?2, "
|
||||||
"whitelisted = ?3, "
|
"whitelisted = ?3, "
|
||||||
"mod = ?4, "
|
"mod = ?4, "
|
||||||
"admin = ?5 "
|
"admin = ?5 "
|
||||||
"WHERE uid = ?1;";
|
"WHERE uid = ?1;";
|
||||||
|
|
||||||
static const char* DELETE_USER_ACCOUNT = "DELETE FROM UserAccounts WHERE uid = ?;";
|
static const char* DELETE_USER_ACCOUNT = "DELETE FROM Accounts WHERE uid = ?;";
|
||||||
|
|
||||||
static const char* COUNT_USER_ACCOUNT_RECORDS = "SELECT COUNT(*) FROM UserAccounts;";
|
static const char* COUNT_USER_ACCOUNT_RECORDS = "SELECT COUNT(*) FROM Accounts;";
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//Define the public methods
|
//Define the public methods
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
#include "character_defines.hpp"
|
#include "character_defines.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -36,7 +35,7 @@
|
|||||||
//NOTE: Programmer set variables are NOT zero-indexed
|
//NOTE: Programmer set variables are NOT zero-indexed
|
||||||
//NOTE: SQLite3 returned variables (i.e. loading) ARE zero-indexed
|
//NOTE: SQLite3 returned variables (i.e. loading) ARE zero-indexed
|
||||||
|
|
||||||
static const char* CREATE_CHARACTER = "INSERT INTO LiveCharacters ("
|
static const char* CREATE_CHARACTER = "INSERT INTO Characters ("
|
||||||
"owner, "
|
"owner, "
|
||||||
"handle, "
|
"handle, "
|
||||||
"avatar, "
|
"avatar, "
|
||||||
@@ -58,9 +57,9 @@ static const char* LOAD_CHARACTER = "SELECT "
|
|||||||
"boundsY, "
|
"boundsY, "
|
||||||
"boundsW, "
|
"boundsW, "
|
||||||
"boundsH "
|
"boundsH "
|
||||||
"FROM LiveCharacters WHERE handle = ?;";
|
"FROM Characters WHERE handle = ?;";
|
||||||
|
|
||||||
static const char* SAVE_CHARACTER = "UPDATE OR FAIL LiveCharacters SET "
|
static const char* SAVE_CHARACTER = "UPDATE OR FAIL Characters SET "
|
||||||
"roomIndex = ?2, "
|
"roomIndex = ?2, "
|
||||||
"originX = ?3, "
|
"originX = ?3, "
|
||||||
"originY = ?4, "
|
"originY = ?4, "
|
||||||
@@ -70,9 +69,9 @@ static const char* SAVE_CHARACTER = "UPDATE OR FAIL LiveCharacters SET "
|
|||||||
"boundsH = ?8 "
|
"boundsH = ?8 "
|
||||||
"WHERE uid = ?1;";
|
"WHERE uid = ?1;";
|
||||||
|
|
||||||
static const char* DELETE_CHARACTER = "DELETE FROM LiveCharacters WHERE uid = ?;";
|
static const char* DELETE_CHARACTER = "DELETE FROM Characters WHERE uid = ?;";
|
||||||
|
|
||||||
static const char* COUNT_CHARACTER_RECORDS = "SELECT COUNT(*) FROM LiveCharacters;";
|
static const char* COUNT_CHARACTER_RECORDS = "SELECT COUNT(*) FROM Characters;";
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//Define the methods
|
//Define the methods
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#ifndef CLIENTDATA_HPP_
|
#ifndef CLIENTDATA_HPP_
|
||||||
#define CLIENTDATA_HPP_
|
#define CLIENTDATA_HPP_
|
||||||
|
|
||||||
#include "SDL_net.h"
|
#include "SDL/SDL_net.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
#include "server_packet.hpp"
|
#include "server_packet.hpp"
|
||||||
#include "singleton.hpp"
|
#include "singleton.hpp"
|
||||||
|
|
||||||
#include "SDL_net.h"
|
#include "SDL/SDL_net.h"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public:
|
|||||||
const char* GetType() const;
|
const char* GetType() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Entity(const char* type);
|
Entity(const char*);
|
||||||
virtual ~Entity() = default;
|
virtual ~Entity() = default;
|
||||||
|
|
||||||
int roomIndex = -1;
|
int roomIndex = -1;
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
+4
-4
@@ -41,8 +41,8 @@
|
|||||||
#include "character_manager_api.hpp"
|
#include "character_manager_api.hpp"
|
||||||
#include "region_api.hpp"
|
#include "region_api.hpp"
|
||||||
#include "region_pager_api.hpp"
|
#include "region_pager_api.hpp"
|
||||||
//#include "monster_api.hpp"
|
#include "monster_api.hpp"
|
||||||
//#include "monster_manager_api.hpp"
|
#include "monster_manager_api.hpp"
|
||||||
#include "network_api.hpp"
|
#include "network_api.hpp"
|
||||||
#include "room_api.hpp"
|
#include "room_api.hpp"
|
||||||
#include "room_manager_api.hpp"
|
#include "room_manager_api.hpp"
|
||||||
@@ -70,8 +70,8 @@ static const luaL_Reg preloadedlibs[] = {
|
|||||||
{TORTUGA_ENTITY_API, openEntityAPI}, //required by derived classes
|
{TORTUGA_ENTITY_API, openEntityAPI}, //required by derived classes
|
||||||
{TORTUGA_CHARACTER_API, openCharacterAPI},
|
{TORTUGA_CHARACTER_API, openCharacterAPI},
|
||||||
{TORTUGA_CHARACTER_MANAGER_API, openCharacterManagerAPI},
|
{TORTUGA_CHARACTER_MANAGER_API, openCharacterManagerAPI},
|
||||||
// {TORTUGA_MONSTER_API, openMonsterAPI},
|
{TORTUGA_MONSTER_API, openMonsterAPI},
|
||||||
// {TORTUGA_MONSTER_MANAGER_API, openMonsterManagerAPI},
|
{TORTUGA_MONSTER_MANAGER_API, openMonsterManagerAPI},
|
||||||
{TORTUGA_NETWORK_API, openNetworkAPI},
|
{TORTUGA_NETWORK_API, openNetworkAPI},
|
||||||
{TORTUGA_REGION_API, openRegionAPI},
|
{TORTUGA_REGION_API, openRegionAPI},
|
||||||
{TORTUGA_REGION_PAGER_API, openRegionPagerAPI},
|
{TORTUGA_REGION_PAGER_API, openRegionPagerAPI},
|
||||||
|
|||||||
+2
-12
@@ -1,5 +1,5 @@
|
|||||||
#include directories
|
#include directories
|
||||||
INCLUDES+=SDL . accounts characters clients entities rooms server_utilities triggers ../common/debugging ../common/gameplay ../common/map ../common/network ../common/network/packet_types ../common/utilities
|
INCLUDES+=. accounts characters clients entities monsters rooms server_utilities triggers ../common/debugging ../common/gameplay ../common/map ../common/network ../common/network/packet_types ../common/utilities
|
||||||
|
|
||||||
#libraries
|
#libraries
|
||||||
#the order of the $(LIBS) is important, at least for MinGW
|
#the order of the $(LIBS) is important, at least for MinGW
|
||||||
@@ -8,10 +8,6 @@ ifeq ($(OS),Windows_NT)
|
|||||||
LIBS+=-lwsock32 -liphlpapi -lmingw32
|
LIBS+=-lwsock32 -liphlpapi -lmingw32
|
||||||
endif
|
endif
|
||||||
LIBS+=-lSDLmain -lSDL -llua -lsqlite3
|
LIBS+=-lSDLmain -lSDL -llua -lsqlite3
|
||||||
ifeq ($(shell uname), Linux)
|
|
||||||
#I don't know what this does, but Ubuntu needs it
|
|
||||||
LIBS+=-ldl
|
|
||||||
endif
|
|
||||||
|
|
||||||
#flags
|
#flags
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
@@ -33,7 +29,7 @@ all: $(OBJ) $(OUT)
|
|||||||
$(MAKE) -C characters
|
$(MAKE) -C characters
|
||||||
$(MAKE) -C clients
|
$(MAKE) -C clients
|
||||||
$(MAKE) -C entities
|
$(MAKE) -C entities
|
||||||
# $(MAKE) -C monsters
|
$(MAKE) -C monsters
|
||||||
$(MAKE) -C rooms
|
$(MAKE) -C rooms
|
||||||
$(MAKE) -C server_utilities
|
$(MAKE) -C server_utilities
|
||||||
$(MAKE) -C triggers
|
$(MAKE) -C triggers
|
||||||
@@ -53,12 +49,6 @@ $(OBJDIR)/%.o: %.cpp
|
|||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
$(RM) *.o *.a *.exe
|
$(RM) *.o *.a *.exe
|
||||||
else ifeq ($(shell uname), Linux)
|
|
||||||
find . -type f -name *.o -exec rm -f -r -v {} \;
|
|
||||||
find . -type f -name *.a -exec rm -f -r -v {} \;
|
|
||||||
rm -f -v out/client out/server
|
|
||||||
endif
|
|
||||||
|
|
||||||
rebuild: clean all
|
rebuild: clean all
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
static int setAvatar(lua_State* L) {
|
static int setAvatar(lua_State* L) {
|
||||||
MonsterData* monster = static_cast<MonsterData*>(lua_touserdata(L, 1));
|
MonsterData* monster = static_cast<MonsterData*>(lua_touserdata(L, 1));
|
||||||
monster->SetAvatar(lua_tostring(L, 2));
|
monster->SetAvatar(lua_tostring(L, 2));
|
||||||
//TODO: (1) send an update to the clients?
|
//TODO: send an update to the clients?
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,23 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "monster_data.hpp"
|
#include "monster_data.hpp"
|
||||||
|
|
||||||
MonsterData::MonsterData(std::string _avatar, int _scriptRef):
|
MonsterData::MonsterData(): Entity("monster") {
|
||||||
Entity("monster"),
|
|
||||||
avatar(_avatar),
|
|
||||||
scriptRef(_scriptRef)
|
|
||||||
{
|
|
||||||
//EMPTY
|
//EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
void MonsterData::Update() {
|
|
||||||
Entity::Update();
|
|
||||||
//TODO: (0) call the script reference
|
|
||||||
}
|
|
||||||
|
|
||||||
//-------------------------
|
|
||||||
//accessors & mutators
|
|
||||||
//-------------------------
|
|
||||||
|
|
||||||
std::string MonsterData::SetAvatar(std::string s) {
|
std::string MonsterData::SetAvatar(std::string s) {
|
||||||
return avatar = s;
|
return avatar = s;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,22 +28,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
/* DOCS: Monster attributes, read more
|
|
||||||
* species (avatar, script)
|
|
||||||
* level
|
|
||||||
* health/mana
|
|
||||||
* permadeath/respawn
|
|
||||||
*/
|
|
||||||
|
|
||||||
class MonsterData: public Entity {
|
class MonsterData: public Entity {
|
||||||
public:
|
public:
|
||||||
MonsterData(std::string avatar, int scriptRef);
|
MonsterData();
|
||||||
~MonsterData() = default;
|
~MonsterData() = default;
|
||||||
|
|
||||||
virtual void Update();
|
|
||||||
|
|
||||||
//accessors & mutators
|
|
||||||
|
|
||||||
std::string SetAvatar(std::string);
|
std::string SetAvatar(std::string);
|
||||||
std::string GetAvatar();
|
std::string GetAvatar();
|
||||||
|
|
||||||
|
|||||||
@@ -29,66 +29,46 @@ MonsterManager::~MonsterManager() {
|
|||||||
UnloadAll();
|
UnloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
int MonsterManager::Create(std::string avatar, int scriptRef) {
|
int MonsterManager::Create(std::string) {
|
||||||
//implicitly create the new
|
//TODO: (9) MonsterManager::Create()
|
||||||
elementMap.emplace(counter, MonsterData(avatar, scriptRef));
|
|
||||||
|
|
||||||
//TODO: do various things like saving to the database
|
|
||||||
return counter++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: (1) monster load, save
|
|
||||||
|
|
||||||
void MonsterManager::Unload(int uid) {
|
void MonsterManager::Unload(int uid) {
|
||||||
elementMap.erase(uid);
|
//TODO: (9) MonsterManager::Unload()
|
||||||
}
|
}
|
||||||
|
|
||||||
void MonsterManager::UnloadAll() {
|
void MonsterManager::UnloadAll() {
|
||||||
elementMap.clear();
|
//TODO: (9) MonsterManager::UnloadAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
void MonsterManager::UnloadIf(std::function<bool(std::pair<const int, MonsterData const&>)> fn) {
|
void MonsterManager::UnloadIf(std::function<bool(std::pair<const int, MonsterData const&>)> fn) {
|
||||||
std::map<int, MonsterData>::iterator it = elementMap.begin();
|
//TODO: (9) MonsterManager::UnloadIf()
|
||||||
while (it != elementMap.end()) {
|
|
||||||
if (fn(*it)) {
|
|
||||||
it = elementMap.erase(it);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
++it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MonsterData* MonsterManager::Get(int uid) {
|
MonsterData* MonsterManager::Get(int uid) {
|
||||||
std::map<int, MonsterData>::iterator it = elementMap.find(uid);
|
//TODO: (9) MonsterManager::Get()
|
||||||
|
|
||||||
if (it == elementMap.end()) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return &it->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MonsterManager::GetLoadedCount() {
|
int MonsterManager::GetLoadedCount() {
|
||||||
return elementMap.size();
|
//TODO: (9) MonsterManager::GetLoadedCount()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, MonsterData>* MonsterManager::GetContainer() {
|
std::map<int, MonsterData>* MonsterManager::GetContainer() {
|
||||||
return &elementMap;
|
//TODO: (9) MonsterManager::GetContainer()
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_State* MonsterManager::SetLuaState(lua_State* L) {
|
lua_State* MonsterManager::SetLuaState(lua_State* L) {
|
||||||
return lua = L;
|
//TODO: (9) MonsterManager::SetLuaState()
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_State* MonsterManager::GetLuaState() {
|
lua_State* MonsterManager::GetLuaState() {
|
||||||
return lua;
|
//TODO: (9) MonsterManager::GetLuaState()
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3* MonsterManager::SetDatabase(sqlite3* db) {
|
sqlite3* MonsterManager::SetDatabase(sqlite3* db) {
|
||||||
return database = db;
|
//TODO: (9) MonsterManager::SetDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlite3* MonsterManager::GetDatabase() {
|
sqlite3* MonsterManager::GetDatabase() {
|
||||||
return database;
|
//TODO: (9) MonsterManager::GetDatabase()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
~MonsterManager();
|
~MonsterManager();
|
||||||
|
|
||||||
//common public methods
|
//common public methods
|
||||||
int Create(std::string avatar, int scriptRef);
|
int Create(std::string);
|
||||||
void Unload(int uid);
|
void Unload(int uid);
|
||||||
|
|
||||||
void UnloadAll();
|
void UnloadAll();
|
||||||
@@ -57,7 +57,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
//members
|
//members
|
||||||
std::map<int, MonsterData> elementMap;
|
std::map<int, MonsterData> elementMap;
|
||||||
int counter = 0;
|
|
||||||
lua_State* lua = nullptr;
|
lua_State* lua = nullptr;
|
||||||
sqlite3* database = nullptr;
|
sqlite3* database = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,54 +23,7 @@
|
|||||||
|
|
||||||
#include "monster_manager.hpp"
|
#include "monster_manager.hpp"
|
||||||
|
|
||||||
static int create(lua_State* L) {
|
|
||||||
MonsterManager* mgr = static_cast<MonsterManager* const>(lua_touserdata(L, 1));
|
|
||||||
int index = mgr->Create(lua_tostring(L, 2), lua_tointeger(L, 3));
|
|
||||||
MonsterData* monster = mgr->Get(index);
|
|
||||||
lua_pushlightuserdata(L, static_cast<void*>(monster));
|
|
||||||
lua_pushinteger(L, index);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//TOOD: this needs to take the userdata as a parameter too
|
|
||||||
static int unload(lua_State* L) {
|
|
||||||
MonsterManager* mgr = static_cast<MonsterManager* const>(lua_touserdata(L, 1));
|
|
||||||
mgr->Unload(lua_tointeger(L, 2));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int unloadAll(lua_State* L) {
|
|
||||||
MonsterManager* mgr = static_cast<MonsterManager* const>(lua_touserdata(L, 1));
|
|
||||||
mgr->UnloadAll();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int unloadIf(lua_State* L) {
|
|
||||||
MonsterManager* mgr = static_cast<MonsterManager* const>(lua_touserdata(L, 1));
|
|
||||||
//TODO: unloadIf
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int get(lua_State* L) {
|
|
||||||
MonsterManager* mgr = static_cast<MonsterManager* const>(lua_touserdata(L, 1));
|
|
||||||
MonsterData* monster = mgr->Get(lua_tointeger(L, 2));
|
|
||||||
lua_pushlightuserdata(L, static_cast<void*>(monster));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int getLoadedCount(lua_State* L) {
|
|
||||||
MonsterManager* mgr = static_cast<MonsterManager* const>(lua_touserdata(L, 1));
|
|
||||||
lua_pushinteger(L, mgr->GetLoadedCount());
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg monsterManagerLib[] = {
|
static const luaL_Reg monsterManagerLib[] = {
|
||||||
{"Create", create},
|
|
||||||
{"Unload", unload},
|
|
||||||
{"UnloadAll", unloadAll},
|
|
||||||
// {"UnloadIf", unloadIf},
|
|
||||||
{"Get", get},
|
|
||||||
{"GetLoadedCount", getLoadedCount},
|
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -56,13 +56,11 @@ static int getPager(lua_State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
static int getMonsterMgr(lua_State* L) {
|
static int getMonsterMgr(lua_State* L) {
|
||||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||||
lua_pushlightuserdata(L, reinterpret_cast<void*>(room->GetMonsterMgr()) );
|
lua_pushlightuserdata(L, reinterpret_cast<void*>(room->GetMonsterMgr()) );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
static int getTriggerMgr(lua_State* L) {
|
static int getTriggerMgr(lua_State* L) {
|
||||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||||
@@ -70,6 +68,8 @@ static int getTriggerMgr(lua_State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: character list
|
||||||
|
|
||||||
static int forEachCharacter(lua_State* L) {
|
static int forEachCharacter(lua_State* L) {
|
||||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||||
//pass each character to the given function
|
//pass each character to the given function
|
||||||
@@ -87,26 +87,6 @@ static int forEachCharacter(lua_State* L) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
static int forEachMonster(lua_State* L) {
|
|
||||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
|
||||||
MonsterManager* monsterMgr = room->GetMonsterMgr();
|
|
||||||
//pass each monster to the given function
|
|
||||||
for (auto& it : *monsterMgr->GetContainer()) {
|
|
||||||
lua_pushvalue(L, -1);
|
|
||||||
lua_pushlightuserdata(L, static_cast<void*>(&it.second));
|
|
||||||
//call each iteration, throwing an exception if something happened
|
|
||||||
if (lua_pcall(L, 1, 0, 0) != LUA_OK) {
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "Lua error: ";
|
|
||||||
os << lua_tostring(L, -1);
|
|
||||||
throw(std::runtime_error(os.str()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int setOnTick(lua_State* L) {
|
static int setOnTick(lua_State* L) {
|
||||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, room->GetTickReference());
|
luaL_unref(L, LUA_REGISTRYINDEX, room->GetTickReference());
|
||||||
@@ -140,11 +120,10 @@ static const luaL_Reg roomLib[] = {
|
|||||||
{"GetTileset", getTilesetName},
|
{"GetTileset", getTilesetName},
|
||||||
|
|
||||||
{"GetPager",getPager},
|
{"GetPager",getPager},
|
||||||
// {"GetMonsterMgr",getMonsterMgr},
|
{"GetMonsterMgr",getMonsterMgr},
|
||||||
{"GetTriggerMgr",getTriggerMgr},
|
{"GetTriggerMgr",getTriggerMgr},
|
||||||
|
|
||||||
{"ForEachCharacter", forEachCharacter},
|
{"ForEachCharacter", forEachCharacter},
|
||||||
// {"ForEachMonster", forEachMonster},
|
|
||||||
|
|
||||||
{"SetOnTick", setOnTick},
|
{"SetOnTick", setOnTick},
|
||||||
{"GetOnTick", getOnTick},
|
{"GetOnTick", getOnTick},
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
#include <stack>
|
#include <stack>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
//TODO: (9) character collisions should be preformed client-side
|
|
||||||
void RoomData::RunFrame() {
|
void RoomData::RunFrame() {
|
||||||
//get the hook
|
//get the hook
|
||||||
lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef);
|
lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef);
|
||||||
@@ -122,6 +121,10 @@ RegionPagerLua* RoomData::GetPager() {
|
|||||||
return &pager;
|
return &pager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MonsterManager* RoomData::GetMonsterMgr() {
|
||||||
|
return &monsterMgr;
|
||||||
|
}
|
||||||
|
|
||||||
TriggerManager* RoomData::GetTriggerMgr() {
|
TriggerManager* RoomData::GetTriggerMgr() {
|
||||||
return &triggerMgr;
|
return &triggerMgr;
|
||||||
}
|
}
|
||||||
@@ -133,6 +136,7 @@ std::list<CharacterData*>* RoomData::GetCharacterList() {
|
|||||||
lua_State* RoomData::SetLuaState(lua_State* L) {
|
lua_State* RoomData::SetLuaState(lua_State* L) {
|
||||||
lua = L;
|
lua = L;
|
||||||
pager.SetLuaState(lua);
|
pager.SetLuaState(lua);
|
||||||
|
monsterMgr.SetLuaState(lua);
|
||||||
triggerMgr.SetLuaState(lua);
|
triggerMgr.SetLuaState(lua);
|
||||||
return lua;
|
return lua;
|
||||||
}
|
}
|
||||||
@@ -143,6 +147,7 @@ lua_State* RoomData::GetLuaState() {
|
|||||||
|
|
||||||
sqlite3* RoomData::SetDatabase(sqlite3* db) {
|
sqlite3* RoomData::SetDatabase(sqlite3* db) {
|
||||||
database = db;
|
database = db;
|
||||||
|
monsterMgr.SetDatabase(database);
|
||||||
return database;
|
return database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,11 @@
|
|||||||
#define ROOMDATA_HPP_
|
#define ROOMDATA_HPP_
|
||||||
|
|
||||||
#include "character_data.hpp"
|
#include "character_data.hpp"
|
||||||
|
#include "monster_manager.hpp"
|
||||||
#include "region_pager_lua.hpp"
|
#include "region_pager_lua.hpp"
|
||||||
#include "trigger_manager.hpp"
|
#include "trigger_manager.hpp"
|
||||||
|
|
||||||
#include "lua.hpp"
|
#include "lua.hpp"
|
||||||
#include "sqlite3.h"
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -47,6 +47,7 @@ public:
|
|||||||
std::string GetTileset();
|
std::string GetTileset();
|
||||||
|
|
||||||
RegionPagerLua* GetPager();
|
RegionPagerLua* GetPager();
|
||||||
|
MonsterManager* GetMonsterMgr();
|
||||||
TriggerManager* GetTriggerMgr();
|
TriggerManager* GetTriggerMgr();
|
||||||
std::list<CharacterData*>* GetCharacterList();
|
std::list<CharacterData*>* GetCharacterList();
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ private:
|
|||||||
|
|
||||||
//members
|
//members
|
||||||
RegionPagerLua pager;
|
RegionPagerLua pager;
|
||||||
|
MonsterManager monsterMgr;
|
||||||
TriggerManager triggerMgr;
|
TriggerManager triggerMgr;
|
||||||
std::list<CharacterData*> characterList;
|
std::list<CharacterData*> characterList;
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "account_manager.hpp"
|
#include "account_manager.hpp"
|
||||||
#include "character_manager.hpp"
|
#include "character_manager.hpp"
|
||||||
#include "client_manager.hpp"
|
#include "client_manager.hpp"
|
||||||
|
#include "monster_manager.hpp"
|
||||||
#include "room_manager.hpp"
|
#include "room_manager.hpp"
|
||||||
|
|
||||||
//utilities
|
//utilities
|
||||||
@@ -104,6 +105,9 @@ private:
|
|||||||
void hCharacterAttack(CharacterPacket* const);
|
void hCharacterAttack(CharacterPacket* const);
|
||||||
void hCharacterDamage(CharacterPacket* const);
|
void hCharacterDamage(CharacterPacket* const);
|
||||||
|
|
||||||
|
//character management
|
||||||
|
void hMonsterDamage(MonsterPacket* const);
|
||||||
|
|
||||||
//chat
|
//chat
|
||||||
void hTextBroadcast(TextPacket* const);
|
void hTextBroadcast(TextPacket* const);
|
||||||
void hTextSpeech(TextPacket* const);
|
void hTextSpeech(TextPacket* const);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "server_application.hpp"
|
#include "server_application.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "server_application.hpp"
|
#include "server_application.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "server_application.hpp"
|
#include "server_application.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|||||||
+12
-4
@@ -23,11 +23,11 @@
|
|||||||
|
|
||||||
//utility functions
|
//utility functions
|
||||||
#include "sql_tools.hpp"
|
#include "sql_tools.hpp"
|
||||||
|
#include "userdata.hpp"
|
||||||
|
|
||||||
//std & STL
|
//std & STL
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@@ -52,9 +52,7 @@ void ServerApplication::Init(int argc, char* argv[]) {
|
|||||||
|
|
||||||
//Init SDL
|
//Init SDL
|
||||||
if (SDL_Init(0)) {
|
if (SDL_Init(0)) {
|
||||||
std::ostringstream os;
|
throw(std::runtime_error("Failed to initialize SDL"));
|
||||||
os << "Failed to initialize SDL: " << SDL_GetError();
|
|
||||||
throw(std::runtime_error(os.str()));
|
|
||||||
}
|
}
|
||||||
std::cout << "Initialized SDL" << std::endl;
|
std::cout << "Initialized SDL" << std::endl;
|
||||||
|
|
||||||
@@ -81,6 +79,11 @@ void ServerApplication::Init(int argc, char* argv[]) {
|
|||||||
|
|
||||||
std::cout << "Initialized lua" << std::endl;
|
std::cout << "Initialized lua" << std::endl;
|
||||||
|
|
||||||
|
//create the userdata metatable
|
||||||
|
createUserdataMetatable(luaState);
|
||||||
|
|
||||||
|
std::cout << "\tCreated userdata metatable" << std::endl;
|
||||||
|
|
||||||
//append config["dir.scripts"] to the module path
|
//append config["dir.scripts"] to the module path
|
||||||
if (config["dir.scripts"].size() > 0) {
|
if (config["dir.scripts"].size() > 0) {
|
||||||
//get the original path
|
//get the original path
|
||||||
@@ -327,6 +330,11 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) {
|
|||||||
hCharacterDamage(static_cast<CharacterPacket*>(argPacket));
|
hCharacterDamage(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//monster management
|
||||||
|
case SerialPacketType::MONSTER_DAMAGE:
|
||||||
|
hMonsterDamage(static_cast<MonsterPacket*>(argPacket));
|
||||||
|
break;
|
||||||
|
|
||||||
//chat
|
//chat
|
||||||
case SerialPacketType::TEXT_BROADCAST:
|
case SerialPacketType::TEXT_BROADCAST:
|
||||||
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "server_application.hpp"
|
#include "server_application.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013-2015
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "server_application.hpp"
|
||||||
|
|
||||||
|
void ServerApplication::hMonsterDamage(MonsterPacket* const argPacket) {
|
||||||
|
//TODO: (9) ServerApplication::hMonsterDamage()
|
||||||
|
}
|
||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
#include "character_manager.hpp"
|
#include "character_manager.hpp"
|
||||||
#include "server_utilities.hpp"
|
#include "server_utilities.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
static int pumpCharacterUpdate(lua_State* L) {
|
static int pumpCharacterUpdate(lua_State* L) {
|
||||||
CharacterData* characterData = static_cast<CharacterData*>(lua_touserdata(L, 1));
|
CharacterData* characterData = static_cast<CharacterData*>(lua_touserdata(L, 1));
|
||||||
|
|
||||||
@@ -64,13 +62,8 @@ static int pumpCharacterUpdate(lua_State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pumpMonsterUpdate(lua_State* L) {
|
|
||||||
//TODO: (0) send the info about a specific monster instance
|
|
||||||
}
|
|
||||||
|
|
||||||
static const luaL_Reg networkLib[] = {
|
static const luaL_Reg networkLib[] = {
|
||||||
{"PumpCharacterUpdate", pumpCharacterUpdate},
|
{"PumpCharacterUpdate", pumpCharacterUpdate},
|
||||||
{"PumpMonsterUpdate", pumpMonsterUpdate},
|
|
||||||
{nullptr, nullptr}
|
{nullptr, nullptr}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@
|
|||||||
#include "room_manager.hpp"
|
#include "room_manager.hpp"
|
||||||
#include "udp_network_utility.hpp"
|
#include "udp_network_utility.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//manager unload functions
|
//manager unload functions
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013-2015
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#include "userdata.hpp"
|
||||||
|
|
||||||
|
#define METAMETA "__metameta"
|
||||||
|
|
||||||
|
static int index(lua_State* L) {
|
||||||
|
//get __metameta
|
||||||
|
lua_getmetatable(L, 1); //get the userdata metatable
|
||||||
|
lua_pushstring(L, METAMETA); //push the __metameta name
|
||||||
|
lua_gettable(L, -2); //get the __metameta field from the metatable
|
||||||
|
|
||||||
|
//get __metameta[userdata]
|
||||||
|
lua_pushvalue(L, 1); //copy of the userdata
|
||||||
|
lua_gettable(L, -2); //get the table at __metameta[userdata]
|
||||||
|
|
||||||
|
//table doesn't exist yet
|
||||||
|
if (lua_isnil(L, -1)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//get the value at __metameta[userdata][key]
|
||||||
|
lua_pushvalue(L, 2); //copy the key
|
||||||
|
lua_gettable(L, -2); //get value from the deepest table
|
||||||
|
|
||||||
|
//return
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int newindex(lua_State* L) {
|
||||||
|
//get __metameta
|
||||||
|
lua_getmetatable(L, 1); //get the userdata metatable
|
||||||
|
lua_pushstring(L, METAMETA); //push the __metameta name
|
||||||
|
lua_gettable(L, -2); //get the __metameta field from the metatable
|
||||||
|
|
||||||
|
//get __metameta[userdata]
|
||||||
|
lua_pushvalue(L, 1); //copy of the userdata
|
||||||
|
lua_gettable(L, -2); //get the table at __metameta[userdata]
|
||||||
|
|
||||||
|
//if this table doesn't exist yet
|
||||||
|
if (lua_isnil(L, -1)) {
|
||||||
|
lua_pop(L, 1); //pop nil
|
||||||
|
|
||||||
|
lua_pushvalue(L, 1); //copy userdata (key)
|
||||||
|
lua_createtable(L, 0, 0); //new table (value)
|
||||||
|
lua_settable(L, -3); //create the new table in __metameta
|
||||||
|
|
||||||
|
lua_pushvalue(L, 1); //copy userdata (key)
|
||||||
|
lua_gettable(L, -2); //get the newly created table
|
||||||
|
}
|
||||||
|
|
||||||
|
//set the value at __metameta[userdata][key] = value
|
||||||
|
lua_pushvalue(L, 2); //copy the key
|
||||||
|
lua_pushvalue(L, 3); //copy the value
|
||||||
|
lua_settable(L, -3); //set value in the deepest table
|
||||||
|
|
||||||
|
//return
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static luaL_Reg metatable[] = {
|
||||||
|
{"__index", index},
|
||||||
|
{"__newindex", newindex},
|
||||||
|
{nullptr, nullptr}
|
||||||
|
};
|
||||||
|
|
||||||
|
int createUserdataMetatable(lua_State* L) {
|
||||||
|
//create the userdata metatable
|
||||||
|
lua_pushlightuserdata(L, nullptr); //anon userdata
|
||||||
|
lua_createtable(L, 0, 0); //table
|
||||||
|
|
||||||
|
//insert meta-metatable
|
||||||
|
lua_pushstring(L, METAMETA);
|
||||||
|
lua_createtable(L, 0, 0);
|
||||||
|
lua_settable(L, -3);
|
||||||
|
|
||||||
|
//insert metatable blocker
|
||||||
|
lua_pushstring(L, "__metatable");
|
||||||
|
lua_createtable(L, 0, 0);
|
||||||
|
lua_settable(L, -3);
|
||||||
|
|
||||||
|
//insert metamethods
|
||||||
|
for (luaL_Reg* it = metatable; it->name; it++) {
|
||||||
|
lua_pushstring(L, it->name);
|
||||||
|
lua_pushcfunction(L, it->func);
|
||||||
|
lua_settable(L, -3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//set in the object & pop the anon userdata
|
||||||
|
lua_setmetatable(L, -2); //set the metatable for userdata
|
||||||
|
lua_pop(L, 1); //pop the anon userdata
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2013-2015
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef METATABLES_HPP_
|
||||||
|
#define METATABLES_HPP_
|
||||||
|
|
||||||
|
#include "lua.hpp"
|
||||||
|
|
||||||
|
int createUserdataMetatable(lua_State* L);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -30,3 +30,8 @@ $(OUTDIR):
|
|||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
$(OBJDIR)/%.o: %.cpp
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.a *.exe
|
||||||
|
|
||||||
|
rebuild: clean all
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
TODO: upgrade to lua 5.3
|
TODO: upgrade to lua 5.3
|
||||||
TODO: upgrade to SDL 2.0
|
|
||||||
TODO: Split config.cfg in two, one for the server and the client
|
TODO: Split config.cfg in two, one for the server and the client
|
||||||
TODO: Consistency for bounds names
|
TODO: Consistency for bounds names
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user