Compare commits

...

29 Commits

Author SHA1 Message Date
Kayne Ruse f82b0a8843 Merge branch 'develop', read more
* moved network_api.*pp
* Added copyright notices to scripts
* Changed SQL table names (including hardcoded usage)
* Added monster tables to the database
* Made updates.sql (unneeded, and deleted)
* Added ForEachMonster() to the room API (incomplete)
* Created class MonsterData (incomplete)
* Created class MonsterManager (incomplete)
* Created MonsterManager API (incomplete)
2015-07-07 12:52:46 +10:00
Kayne Ruse 210bccbe0d Pruned the usage of the incomplete monster system 2015-07-07 12:41:57 +10:00
Kayne Ruse 68429806d1 Merge branch 'master' into develop 2015-05-18 21:29:15 +10:00
Kayne Ruse a8cf0a6947 Updated .gitignore 2015-05-18 21:28:55 +10:00
Kayne Ruse 822d0636cc Merge branch 'master' into develop 2015-05-17 12:38:44 +10:00
Kayne Ruse 164a3e18d9 Fixed formatting 2015-05-17 12:36:43 +10:00
Kayne Ruse 3498b5d154 Merge branch 'ubuntu-build'
Conflicts:
	README.md

After setting up my new PC's build environment, I've made some changes to make
both setups compatible.
2015-05-17 12:33:31 +10:00
Kayne Ruse 96c10da527 Tweaked README.md 2015-05-17 09:48:49 +10:00
Kayne Ruse 3856b3cdd2 DELETE ME: temporary commit 2015-05-17 09:36:37 +10:00
Kayne Ruse 661f6db82c Added the linux release to README.md 2015-05-17 09:28:37 +10:00
Kayne Ruse 99b35483f8 Tenative port for Linux 2015-05-17 09:18:46 +10:00
Kayne Ruse 102ba18b7b Finally wrote the monster manager API 2015-05-08 23:17:35 +10:00
Kayne Ruse 07faf1b96b Moved a file 2015-05-08 22:33:46 +10:00
Kayne Ruse 1d70e271b6 Merge branch 'master' into develop 2015-04-28 11:03:58 +10:00
Kayne Ruse 0bf5ccee4d Spelling correction 2015-04-28 11:03:44 +10:00
Kayne Ruse 35e7d0cf61 Tweaked scripts, added ForEachMonster()
(cherry picked from commit 0cf6a3dceb56a85969e8248e19f9143364b75c68)
2015-04-28 10:25:12 +10:00
Kayne Ruse 27fd810cfd Added a simple database update script, and comment headers
I don't know why it took me this long to add those headers in the first
place.

(cherry picked from commit 3c28b6c3bf75c4bdb42e5ea9d9864efaa855620c)
2015-04-28 10:24:47 +10:00
Kayne Ruse 8903b1e28d Began marking changes for monsters
These changes include storing monsters on shutdown, storing dead
characters and monsters, etc. Also fleshed out the MonsterManager's
internals a bit.

(cherry picked from commit af982710f6de050c09ef503cf2f8e1c9fdd34979)
2015-04-28 10:24:17 +10:00
Kayne Ruse c1ace69e19 Merge branch 'bug-hunting' 2015-04-28 06:04:06 +10:00
Kayne Ruse 5c404c572e Patched bug #45 without resolving it 2015-04-28 06:01:58 +10:00
Kayne Ruse 878d502b8b Looking for the bug 2015-04-27 01:35:14 +10:00
Kayne Ruse 2a1ee4acbf tmp 2015-04-26 03:29:33 +10:00
Kayne Ruse 0e149acc62 Pointless tweak 2015-04-26 03:24:25 +10:00
Kayne Ruse 63e4394583 I can't seem to pinpoint the cause 2015-04-26 03:11:00 +10:00
Kayne Ruse 7aeabf0d14 Hunting a strange networking bug 2015-04-26 02:14:26 +10:00
Kayne Ruse 9d5a668045 Merge branch 'develop', read more
The trigger system has been fully implemented, as well as a few other
tweaks as the occasional thought came to mind.

Multiple rooms are now fully functional, mostly as a way to test the
triggers. Although there are still no real generation algorithms, a
utility for creating door pairs between given rooms is included in the
scripts directory.

Other changes in this merge include:

* Network updates via lua
* Entity types can be determined in lua
* Database columns are now order independant

It should be noted that only two types of userdata will work as far as
entity names are concerned: Characters and Monsters. I tried getting it to
work for all objects passed to lua, but it proved to be too obtuse.

In theory, I could create a teleport puzzle using what I've written here.
That might be a side project, or a way to test saving & loading systems. I
don't see any reason to delay monsters any longer; hopefully, I can get
them going soon too.
2015-03-13 21:28:05 +11:00
Kayne Ruse 894b53e760 Merge branch 'develop' 2015-02-27 02:45:19 +11:00
Kayne Ruse eff23352aa Merge branch 'develop'
Changes:

* "ticking" rooms
* character API
* bare-bones character manager API
* bounds checking in serial_utility.cpp

I have an idea for swapping the existing utility/singleton classes for
namesapces, as I think this would reduce the verbosity that I have to deal
with.
2015-02-23 01:54:46 +11:00
Kayne Ruse fa4ccb6596 Merge branch 'develop' 2015-02-14 23:54:35 +11:00
65 changed files with 449 additions and 220 deletions
+3
View File
@@ -9,6 +9,9 @@
Release/
Debug/
Out/
release/
debug/
out/
#Project generated files
*.db
+7 -5
View File
@@ -1,12 +1,13 @@
## Outline
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.
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.
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.
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.
## Releases
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 Windows can be found [here](https://dl.dropboxusercontent.com/u/46669050/Tortuga-win.rar).
* The most recent stable build for Linux can be found [here](https://dl.dropboxusercontent.com/u/46669050/Tortuga-linux.tar).
## Documentation
@@ -16,13 +17,14 @@ The most recent stable build for Windows can be found [here](https://dl.dropboxu
## External Dependencies
* [SDL 1.2](http://www.libsdl.org/) - Simple DirectMedia Layer API
* [SDL_net 1.2](http://www.libsdl.org/projects/SDL_net/) - SDL's networking extension
* [SDL_net 2.0](http://www.libsdl.org/projects/SDL_net/) - SDL's networking extension
* [lua 5.2](http://www.lua.org/) - The lua programming language
* [SQLite3](http://www.sqlite.org/) - A lightweight SQL database engine
## Tools
* [WinRAR](http://www.rarlab.com/) - The best compression tool available IMO; only needed for distribution
* [WinRAR](http://www.rarlab.com/) - The best compression tool available IMO; only needed for Windows distribution
* [Dropbox](https://www.dropbox.com/) - For hosting and distribution
## Copyright
+4 -1
View File
@@ -27,6 +27,7 @@
#include <stdexcept>
#include <chrono>
#include <iostream>
#include <sstream>
//-------------------------
//Scene headers
@@ -57,7 +58,9 @@ void ClientApplication::Init(int argc, char* argv[]) {
//initialize SDL
if (SDL_Init(SDL_INIT_VIDEO)) {
throw(std::runtime_error("Failed to initialize SDL"));
std::ostringstream os;
os << "Failed to initialize SDL: " << SDL_GetError();
throw(std::runtime_error(os.str()));
}
std::cout << "Initialized SDL" << std::endl;
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
@@ -23,6 +23,7 @@
#include "channels.hpp"
#include <cstring>
#include <iostream>
#include <sstream>
#include <stdexcept>
+17 -3
View File
@@ -22,11 +22,12 @@
#include "world.hpp"
#include "channels.hpp"
#include "terminal_error.hpp"
#include <stdexcept>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
@@ -125,8 +126,16 @@ void World::Update() {
it.second.Update();
}
//update the map
UpdateMap();
try {
//update the map
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
if (!localCharacter) {
@@ -162,6 +171,11 @@ void World::Render(SDL_Surface* const screen) {
//draw the map
for (std::list<Region>::iterator it = regionPager.GetContainer()->begin(); it != regionPager.GetContainer()->end(); it++) {
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
+40 -1
View File
@@ -23,6 +23,24 @@
#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
//-------------------------
@@ -40,6 +58,13 @@ void World::SendRegionRequest(int roomIndex, int x, int y) {
}
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
regionPager.UnloadIf([&](Region const& region) -> bool {
return region.GetX() == argPacket->x && region.GetY() == argPacket->y;
@@ -71,9 +96,23 @@ void World::UpdateMap() {
//request empty regions within this zone
for (int i = xStart; i <= xEnd; i += REGION_WIDTH) {
for (int j = yStart; j <= yEnd; j += REGION_HEIGHT) {
if (!regionPager.FindRegion(i, j)) {
Region* region = regionPager.FindRegion(i, j);
if (!region) {
//request absent region
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()));
}
}
}
}
+7 -1
View File
@@ -1,5 +1,5 @@
#include directories
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
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
#libraries
#the order of the $(LIBS) is important, at least for MinGW
@@ -45,6 +45,12 @@ $(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
ifeq ($(OS),Windows_NT)
$(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
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -6,8 +6,3 @@ all:
$(MAKE) -C network
$(MAKE) -C ui
$(MAKE) -C utilities
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+1
View File
@@ -70,6 +70,7 @@ Region* RegionPagerBase::FindRegion(int x, int y) {
}
Region* RegionPagerBase::PushRegion(Region* const ptr) {
//BUG: #45 Some regions are occasionally losing their tile data
regionList.push_front(*ptr);
return &regionList.front();
}
-5
View File
@@ -31,8 +31,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
@@ -24,7 +24,7 @@
#include "serial_packet_type.hpp"
#include "SDL/SDL_net.h"
#include "SDL_net.h"
constexpr int PACKET_STRING_SIZE = 100;
+1 -1
View File
@@ -27,7 +27,7 @@
#include "singleton.hpp"
//APIs
#include "SDL/SDL_net.h"
#include "SDL_net.h"
class UDPNetworkUtility : public Singleton<UDPNetworkUtility> {
public:
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+1 -1
View File
@@ -22,7 +22,7 @@
#ifndef IPOPERATORS_HPP_
#define IPOPERATORS_HPP_
#include "SDL/SDL_net.h"
#include "SDL_net.h"
//these should've come standard
bool operator==(IPaddress lhs, IPaddress rhs);
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+12 -2
View File
@@ -19,13 +19,23 @@ release: clean all package
#For use on my machine ONLY
package:
rar a -r -ep Tortuga.rar $(OUTDIR)/*.exe $(OUTDIR)/*.dll
rar a -r Tortuga.rar rsc/* copyright.txt instructions.txt
ifeq ($(OS),Windows_NT)
rar a -r -ep Tortuga-win.rar $(OUTDIR)/*.exe $(OUTDIR)/*.dll
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):
mkdir $(OUTDIR)
clean:
ifeq ($(OS),Windows_NT)
$(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
+26
View File
@@ -1,3 +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.
*/
--]]
--DOCS: a placeholder door utility
local doorUtility = {}
roomAPI = require("room")
+32
View File
@@ -1,3 +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.
*/
--]]
--DOCS: a placeholder map generator
local regionAPI = require("region")
local mapMaker = {}
@@ -65,6 +91,9 @@ end
--custom generation systems here
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
for i = 1, regionAPI.GetWidth(r) do
for j = 1, regionAPI.GetHeight(r) do
@@ -95,6 +124,9 @@ function mapMaker.DebugIsland(r)
end
function mapMaker.DebugGrassland(r)
--debug
io.write("map_maker:DebugGrassland(", regionAPI.GetX(r), ", ", regionAPI.GetY(r), ")\n")
--all dirt
for i = 1, regionAPI.GetWidth(r) do
for j = 1, regionAPI.GetHeight(r) do
+26 -2
View File
@@ -1,14 +1,38 @@
--[[
/* 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 mapSaver = {}
function mapSaver.Load(r)
--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
function mapSaver.Save(r)
--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
--TODO: (3) create a flexible saving & loading system
+28 -3
View File
@@ -1,3 +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.
*/
--]]
--DOCS: This script is run by the server on startup
print("Lua script check")
--requirements
@@ -27,10 +53,9 @@ end)
--NOTE: room 0 is the first that the client asks for, therefore it must exist
local overworld, uidOne = roomManagerAPI.CreateRoom("overworld", "overworld.bmp")
roomAPI.Initialize(overworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugIsland, mapSaver.Save)
local underworld, uidTwo = roomManagerAPI.CreateRoom("underworld", "overworld.bmp")
roomAPI.Initialize(underworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugGrassland, mapSaver.Save)
--call the monstrosity
doorUtility.createDoorPair("pair 1", overworld, 0, -64, underworld, 0, 0)
print("Finished the lua script")
doorUtility.createDoorPair("pair 1", overworld, -64, -64, underworld, 64, 64)
+60 -11
View File
@@ -1,6 +1,26 @@
--TODO: (3) An archive table of all dead characters
/* 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.
*/
CREATE TABLE IF NOT EXISTS Accounts (
CREATE TABLE IF NOT EXISTS UserAccounts (
uid INTEGER PRIMARY KEY AUTOINCREMENT,
username varchar(100) UNIQUE, --TODO: (3) Swap username for email address
@@ -15,7 +35,7 @@ CREATE TABLE IF NOT EXISTS Accounts (
admin BIT DEFAULT 0
);
CREATE TABLE IF NOT EXISTS Characters (
CREATE TABLE IF NOT EXISTS LiveCharacters (
uid INTEGER PRIMARY KEY AUTOINCREMENT,
--metadata
@@ -31,16 +51,45 @@ CREATE TABLE IF NOT EXISTS Characters (
boundsX INTEGER DEFAULT 0,
boundsY INTEGER DEFAULT 0,
boundsW INTEGER DEFAULT 0,
boundsH INTEGER DEFAULT 0,
boundsH INTEGER DEFAULT 0
);
--statistics
baseStats INTEGER REFERENCES StatisticSets(uid),
CREATE TABLE IF NOT EXISTS DeadCharacters (
uid INTEGER PRIMARY KEY,
--equipment
weapon INTEGER REFERENCES WornEquipment(uid),
helmet INTEGER REFERENCES WornEquipment(uid),
armour INTEGER REFERENCES WornEquipment(uid)
--etc.
--metadata
owner INTEGER REFERENCES Accounts(uid),
handle varchar(100),
avatar varchar(100),
birth timestamp NOT NULL
);
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)
);
-------------------------
+5 -5
View File
@@ -27,7 +27,7 @@
//Define the queries
//-------------------------
static const char* CREATE_USER_ACCOUNT = "INSERT INTO Accounts (username) VALUES (?);";
static const char* CREATE_USER_ACCOUNT = "INSERT INTO UserAccounts (username) VALUES (?);";
static const char* LOAD_USER_ACCOUNT = "SELECT "
"uid, "
@@ -35,18 +35,18 @@ static const char* LOAD_USER_ACCOUNT = "SELECT "
"whitelisted, "
"mod, "
"admin "
" FROM Accounts WHERE username = ?;";
" FROM UserAccounts WHERE username = ?;";
static const char* SAVE_USER_ACCOUNT = "UPDATE OR FAIL Accounts SET "
static const char* SAVE_USER_ACCOUNT = "UPDATE OR FAIL UserAccounts SET "
"blacklisted = ?2, "
"whitelisted = ?3, "
"mod = ?4, "
"admin = ?5 "
"WHERE uid = ?1;";
static const char* DELETE_USER_ACCOUNT = "DELETE FROM Accounts WHERE uid = ?;";
static const char* DELETE_USER_ACCOUNT = "DELETE FROM UserAccounts WHERE uid = ?;";
static const char* COUNT_USER_ACCOUNT_RECORDS = "SELECT COUNT(*) FROM Accounts;";
static const char* COUNT_USER_ACCOUNT_RECORDS = "SELECT COUNT(*) FROM UserAccounts;";
//-------------------------
//Define the public methods
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+6 -5
View File
@@ -26,6 +26,7 @@
#include "character_defines.hpp"
#include <algorithm>
#include <cstring>
#include <stdexcept>
//-------------------------
@@ -35,7 +36,7 @@
//NOTE: Programmer set variables are NOT zero-indexed
//NOTE: SQLite3 returned variables (i.e. loading) ARE zero-indexed
static const char* CREATE_CHARACTER = "INSERT INTO Characters ("
static const char* CREATE_CHARACTER = "INSERT INTO LiveCharacters ("
"owner, "
"handle, "
"avatar, "
@@ -57,9 +58,9 @@ static const char* LOAD_CHARACTER = "SELECT "
"boundsY, "
"boundsW, "
"boundsH "
"FROM Characters WHERE handle = ?;";
"FROM LiveCharacters WHERE handle = ?;";
static const char* SAVE_CHARACTER = "UPDATE OR FAIL Characters SET "
static const char* SAVE_CHARACTER = "UPDATE OR FAIL LiveCharacters SET "
"roomIndex = ?2, "
"originX = ?3, "
"originY = ?4, "
@@ -69,9 +70,9 @@ static const char* SAVE_CHARACTER = "UPDATE OR FAIL Characters SET "
"boundsH = ?8 "
"WHERE uid = ?1;";
static const char* DELETE_CHARACTER = "DELETE FROM Characters WHERE uid = ?;";
static const char* DELETE_CHARACTER = "DELETE FROM LiveCharacters WHERE uid = ?;";
static const char* COUNT_CHARACTER_RECORDS = "SELECT COUNT(*) FROM Characters;";
static const char* COUNT_CHARACTER_RECORDS = "SELECT COUNT(*) FROM LiveCharacters;";
//-------------------------
//Define the methods
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+1 -1
View File
@@ -22,7 +22,7 @@
#ifndef CLIENTDATA_HPP_
#define CLIENTDATA_HPP_
#include "SDL/SDL_net.h"
#include "SDL_net.h"
#include <chrono>
+1 -1
View File
@@ -26,7 +26,7 @@
#include "server_packet.hpp"
#include "singleton.hpp"
#include "SDL/SDL_net.h"
#include "SDL_net.h"
#include <functional>
#include <list>
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+1 -1
View File
@@ -46,7 +46,7 @@ public:
const char* GetType() const;
protected:
Entity(const char*);
Entity(const char* type);
virtual ~Entity() = default;
int roomIndex = -1;
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+4 -4
View File
@@ -41,8 +41,8 @@
#include "character_manager_api.hpp"
#include "region_api.hpp"
#include "region_pager_api.hpp"
#include "monster_api.hpp"
#include "monster_manager_api.hpp"
//#include "monster_api.hpp"
//#include "monster_manager_api.hpp"
#include "network_api.hpp"
#include "room_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_CHARACTER_API, openCharacterAPI},
{TORTUGA_CHARACTER_MANAGER_API, openCharacterManagerAPI},
{TORTUGA_MONSTER_API, openMonsterAPI},
{TORTUGA_MONSTER_MANAGER_API, openMonsterManagerAPI},
// {TORTUGA_MONSTER_API, openMonsterAPI},
// {TORTUGA_MONSTER_MANAGER_API, openMonsterManagerAPI},
{TORTUGA_NETWORK_API, openNetworkAPI},
{TORTUGA_REGION_API, openRegionAPI},
{TORTUGA_REGION_PAGER_API, openRegionPagerAPI},
+12 -2
View File
@@ -1,5 +1,5 @@
#include directories
INCLUDES+=. accounts characters clients entities monsters rooms server_utilities triggers ../common/debugging ../common/gameplay ../common/map ../common/network ../common/network/packet_types ../common/utilities
INCLUDES+=SDL . accounts characters clients entities rooms server_utilities triggers ../common/debugging ../common/gameplay ../common/map ../common/network ../common/network/packet_types ../common/utilities
#libraries
#the order of the $(LIBS) is important, at least for MinGW
@@ -8,6 +8,10 @@ ifeq ($(OS),Windows_NT)
LIBS+=-lwsock32 -liphlpapi -lmingw32
endif
LIBS+=-lSDLmain -lSDL -llua -lsqlite3
ifeq ($(shell uname), Linux)
#I don't know what this does, but Ubuntu needs it
LIBS+=-ldl
endif
#flags
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
@@ -29,7 +33,7 @@ all: $(OBJ) $(OUT)
$(MAKE) -C characters
$(MAKE) -C clients
$(MAKE) -C entities
$(MAKE) -C monsters
# $(MAKE) -C monsters
$(MAKE) -C rooms
$(MAKE) -C server_utilities
$(MAKE) -C triggers
@@ -49,6 +53,12 @@ $(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
ifeq ($(OS),Windows_NT)
$(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
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+1 -1
View File
@@ -28,7 +28,7 @@
static int setAvatar(lua_State* L) {
MonsterData* monster = static_cast<MonsterData*>(lua_touserdata(L, 1));
monster->SetAvatar(lua_tostring(L, 2));
//TODO: send an update to the clients?
//TODO: (1) send an update to the clients?
return 0;
}
+14 -1
View File
@@ -21,10 +21,23 @@
*/
#include "monster_data.hpp"
MonsterData::MonsterData(): Entity("monster") {
MonsterData::MonsterData(std::string _avatar, int _scriptRef):
Entity("monster"),
avatar(_avatar),
scriptRef(_scriptRef)
{
//EMPTY
}
void MonsterData::Update() {
Entity::Update();
//TODO: (0) call the script reference
}
//-------------------------
//accessors & mutators
//-------------------------
std::string MonsterData::SetAvatar(std::string s) {
return avatar = s;
}
+12 -1
View File
@@ -28,11 +28,22 @@
#include <string>
/* DOCS: Monster attributes, read more
* species (avatar, script)
* level
* health/mana
* permadeath/respawn
*/
class MonsterData: public Entity {
public:
MonsterData();
MonsterData(std::string avatar, int scriptRef);
~MonsterData() = default;
virtual void Update();
//accessors & mutators
std::string SetAvatar(std::string);
std::string GetAvatar();
+32 -12
View File
@@ -29,46 +29,66 @@ MonsterManager::~MonsterManager() {
UnloadAll();
}
int MonsterManager::Create(std::string) {
//TODO: (9) MonsterManager::Create()
int MonsterManager::Create(std::string avatar, int scriptRef) {
//implicitly create the new
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) {
//TODO: (9) MonsterManager::Unload()
elementMap.erase(uid);
}
void MonsterManager::UnloadAll() {
//TODO: (9) MonsterManager::UnloadAll()
elementMap.clear();
}
void MonsterManager::UnloadIf(std::function<bool(std::pair<const int, MonsterData const&>)> fn) {
//TODO: (9) MonsterManager::UnloadIf()
std::map<int, MonsterData>::iterator it = elementMap.begin();
while (it != elementMap.end()) {
if (fn(*it)) {
it = elementMap.erase(it);
}
else {
++it;
}
}
}
MonsterData* MonsterManager::Get(int uid) {
//TODO: (9) MonsterManager::Get()
std::map<int, MonsterData>::iterator it = elementMap.find(uid);
if (it == elementMap.end()) {
return nullptr;
}
return &it->second;
}
int MonsterManager::GetLoadedCount() {
//TODO: (9) MonsterManager::GetLoadedCount()
return elementMap.size();
}
std::map<int, MonsterData>* MonsterManager::GetContainer() {
//TODO: (9) MonsterManager::GetContainer()
return &elementMap;
}
lua_State* MonsterManager::SetLuaState(lua_State* L) {
//TODO: (9) MonsterManager::SetLuaState()
return lua = L;
}
lua_State* MonsterManager::GetLuaState() {
//TODO: (9) MonsterManager::GetLuaState()
return lua;
}
sqlite3* MonsterManager::SetDatabase(sqlite3* db) {
//TODO: (9) MonsterManager::SetDatabase()
return database = db;
}
sqlite3* MonsterManager::GetDatabase() {
//TODO: (9) MonsterManager::GetDatabase()
return database;
}
+2 -1
View File
@@ -37,7 +37,7 @@ public:
~MonsterManager();
//common public methods
int Create(std::string);
int Create(std::string avatar, int scriptRef);
void Unload(int uid);
void UnloadAll();
@@ -57,6 +57,7 @@ public:
private:
//members
std::map<int, MonsterData> elementMap;
int counter = 0;
lua_State* lua = nullptr;
sqlite3* database = nullptr;
};
+47
View File
@@ -23,7 +23,54 @@
#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[] = {
{"Create", create},
{"Unload", unload},
{"UnloadAll", unloadAll},
// {"UnloadIf", unloadIf},
{"Get", get},
{"GetLoadedCount", getLoadedCount},
{nullptr, nullptr}
};
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+24 -3
View File
@@ -56,11 +56,13 @@ static int getPager(lua_State* L) {
return 1;
}
/*
static int getMonsterMgr(lua_State* L) {
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
lua_pushlightuserdata(L, reinterpret_cast<void*>(room->GetMonsterMgr()) );
return 1;
}
*/
static int getTriggerMgr(lua_State* L) {
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
@@ -68,8 +70,6 @@ static int getTriggerMgr(lua_State* L) {
return 1;
}
//TODO: character list
static int forEachCharacter(lua_State* L) {
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
//pass each character to the given function
@@ -87,6 +87,26 @@ static int forEachCharacter(lua_State* L) {
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) {
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
luaL_unref(L, LUA_REGISTRYINDEX, room->GetTickReference());
@@ -120,10 +140,11 @@ static const luaL_Reg roomLib[] = {
{"GetTileset", getTilesetName},
{"GetPager",getPager},
{"GetMonsterMgr",getMonsterMgr},
// {"GetMonsterMgr",getMonsterMgr},
{"GetTriggerMgr",getTriggerMgr},
{"ForEachCharacter", forEachCharacter},
// {"ForEachMonster", forEachMonster},
{"SetOnTick", setOnTick},
{"GetOnTick", getOnTick},
+1 -6
View File
@@ -26,6 +26,7 @@
#include <stack>
#include <stdexcept>
//TODO: (9) character collisions should be preformed client-side
void RoomData::RunFrame() {
//get the hook
lua_rawgeti(lua, LUA_REGISTRYINDEX, tickRef);
@@ -121,10 +122,6 @@ RegionPagerLua* RoomData::GetPager() {
return &pager;
}
MonsterManager* RoomData::GetMonsterMgr() {
return &monsterMgr;
}
TriggerManager* RoomData::GetTriggerMgr() {
return &triggerMgr;
}
@@ -136,7 +133,6 @@ std::list<CharacterData*>* RoomData::GetCharacterList() {
lua_State* RoomData::SetLuaState(lua_State* L) {
lua = L;
pager.SetLuaState(lua);
monsterMgr.SetLuaState(lua);
triggerMgr.SetLuaState(lua);
return lua;
}
@@ -147,7 +143,6 @@ lua_State* RoomData::GetLuaState() {
sqlite3* RoomData::SetDatabase(sqlite3* db) {
database = db;
monsterMgr.SetDatabase(database);
return database;
}
+1 -3
View File
@@ -23,11 +23,11 @@
#define ROOMDATA_HPP_
#include "character_data.hpp"
#include "monster_manager.hpp"
#include "region_pager_lua.hpp"
#include "trigger_manager.hpp"
#include "lua.hpp"
#include "sqlite3.h"
#include <list>
#include <string>
@@ -47,7 +47,6 @@ public:
std::string GetTileset();
RegionPagerLua* GetPager();
MonsterManager* GetMonsterMgr();
TriggerManager* GetTriggerMgr();
std::list<CharacterData*>* GetCharacterList();
@@ -69,7 +68,6 @@ private:
//members
RegionPagerLua pager;
MonsterManager monsterMgr;
TriggerManager triggerMgr;
std::list<CharacterData*> characterList;
-4
View File
@@ -26,7 +26,6 @@
#include "account_manager.hpp"
#include "character_manager.hpp"
#include "client_manager.hpp"
#include "monster_manager.hpp"
#include "room_manager.hpp"
//utilities
@@ -105,9 +104,6 @@ private:
void hCharacterAttack(CharacterPacket* const);
void hCharacterDamage(CharacterPacket* const);
//character management
void hMonsterDamage(MonsterPacket* const);
//chat
void hTextBroadcast(TextPacket* const);
void hTextSpeech(TextPacket* const);
+1
View File
@@ -21,6 +21,7 @@
*/
#include "server_application.hpp"
#include <cstring>
#include <iostream>
#include <sstream>
+1
View File
@@ -21,6 +21,7 @@
*/
#include "server_application.hpp"
#include <cstring>
#include <iostream>
#include <sstream>
+1
View File
@@ -21,6 +21,7 @@
*/
#include "server_application.hpp"
#include <cstring>
#include <iostream>
#include <sstream>
+4 -6
View File
@@ -27,6 +27,7 @@
//std & STL
#include <stdexcept>
#include <chrono>
#include <cstring>
#include <iostream>
#include <list>
#include <sstream>
@@ -51,7 +52,9 @@ void ServerApplication::Init(int argc, char* argv[]) {
//Init SDL
if (SDL_Init(0)) {
throw(std::runtime_error("Failed to initialize SDL"));
std::ostringstream os;
os << "Failed to initialize SDL: " << SDL_GetError();
throw(std::runtime_error(os.str()));
}
std::cout << "Initialized SDL" << std::endl;
@@ -324,11 +327,6 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) {
hCharacterDamage(static_cast<CharacterPacket*>(argPacket));
break;
//monster management
case SerialPacketType::MONSTER_DAMAGE:
hMonsterDamage(static_cast<MonsterPacket*>(argPacket));
break;
//chat
case SerialPacketType::TEXT_BROADCAST:
hTextBroadcast(static_cast<TextPacket*>(argPacket));
+1
View File
@@ -22,6 +22,7 @@
#include "server_application.hpp"
#include <chrono>
#include <cstring>
#include <iostream>
#include <sstream>
-26
View File
@@ -1,26 +0,0 @@
/* 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()
}
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
@@ -25,6 +25,8 @@
#include "character_manager.hpp"
#include "server_utilities.hpp"
#include <cstring>
static int pumpCharacterUpdate(lua_State* L) {
CharacterData* characterData = static_cast<CharacterData*>(lua_touserdata(L, 1));
@@ -62,8 +64,13 @@ static int pumpCharacterUpdate(lua_State* L) {
return 1;
}
static int pumpMonsterUpdate(lua_State* L) {
//TODO: (0) send the info about a specific monster instance
}
static const luaL_Reg networkLib[] = {
{"PumpCharacterUpdate", pumpCharacterUpdate},
{"PumpMonsterUpdate", pumpMonsterUpdate},
{nullptr, nullptr}
};
@@ -27,6 +27,8 @@
#include "room_manager.hpp"
#include "udp_network_utility.hpp"
#include <cstring>
//-------------------------
//manager unload functions
//-------------------------
-5
View File
@@ -30,8 +30,3 @@ $(OUTDIR):
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
+1
View File
@@ -1,4 +1,5 @@
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: Consistency for bounds names