Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c1ace69e19 | |||
| 5c404c572e | |||
| 878d502b8b | |||
| 2a1ee4acbf | |||
| 0e149acc62 | |||
| 63e4394583 | |||
| 7aeabf0d14 | |||
| 9d5a668045 | |||
| 894b53e760 | |||
| eff23352aa | |||
| fa4ccb6596 |
@@ -1,6 +1,6 @@
|
||||
## 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.
|
||||
|
||||
|
||||
@@ -125,8 +125,16 @@ void World::Update() {
|
||||
it.second.Update();
|
||||
}
|
||||
|
||||
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 +170,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
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 ®ionList.front();
|
||||
}
|
||||
|
||||
@@ -65,6 +65,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 +98,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
|
||||
|
||||
@@ -4,11 +4,11 @@ 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
|
||||
|
||||
@@ -31,6 +31,6 @@ local underworld, uidTwo = roomManagerAPI.CreateRoom("underworld", "overworld.bm
|
||||
roomAPI.Initialize(underworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugGrassland, mapSaver.Save)
|
||||
|
||||
--call the monstrosity
|
||||
doorUtility.createDoorPair("pair 1", overworld, 0, -64, underworld, 0, 0)
|
||||
doorUtility.createDoorPair("pair 1", overworld, -64, -64, underworld, 64, 64)
|
||||
|
||||
print("Finished the lua script")
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user