fix ubuntu build

This commit is contained in:
Martin Michelsen
2019-10-16 17:49:57 -07:00
parent 9dbe44b5b6
commit 15fb00f7df
16 changed files with 52 additions and 26 deletions
+2
View File
@@ -1,5 +1,7 @@
#include "ChatCommands.hh"
#include <string.h>
#include <vector>
#include <string>
#include <unordered_map>
+2 -4
View File
@@ -102,7 +102,7 @@ string prs_compress(const string& data) {
prs_compress_ctx pc;
ssize_t read_offset = 0;
while (read_offset < data.size()) {
while (read_offset < static_cast<ssize_t>(data.size())) {
// look for a chunk of data in history matching what's at the current offset
ssize_t best_offset = 0;
@@ -263,7 +263,7 @@ size_t prs_decompress_size(const string& data, size_t max_size) {
size_t output_size = 0;
StringReader r(data.data(), data.size());
int32_t r3, r5;
int32_t r3;
int bitpos = 9;
int16_t currentbyte; // int16_t because it can be -1 when EOF occurs
int flag;
@@ -321,7 +321,6 @@ size_t prs_decompress_size(const string& data, size_t max_size) {
return output_size;
}
r3 = r3 & 0x00000007;
r5 = (offset >> 3) | 0xFFFFE000;
if (r3 == 0) {
flag = 0;
r3 = get_u8_or_eof(r);
@@ -353,7 +352,6 @@ size_t prs_decompress_size(const string& data, size_t max_size) {
return output_size;
}
r3 += 2;
r5 = offset | 0xFFFFFF00;
}
if (r3 == 0) {
continue;
+1
View File
@@ -1,6 +1,7 @@
#include "DNSServer.hh"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <poll.h>
#include <netinet/in.h>
+14 -11
View File
@@ -1,5 +1,7 @@
#include "Items.hh"
#include <string.h>
#include <phosg/Random.hh>
using namespace std;
@@ -143,22 +145,23 @@ void player_use_item_locked(shared_ptr<Lobby> l, shared_ptr<Client> c,
size_t item_index) {
ssize_t equipped_weapon = -1;
ssize_t equipped_armor = -1;
ssize_t equipped_shield = -1;
ssize_t equipped_mag = -1;
// ssize_t equipped_armor = -1;
// ssize_t equipped_shield = -1;
// ssize_t equipped_mag = -1;
for (size_t y = 0; y < c->player.inventory.num_items; y++) {
if (c->player.inventory.items[y].equip_flags & 0x0008) {
if (c->player.inventory.items[y].data.item_data1[0] == 0) {
equipped_weapon = y;
} else if ((c->player.inventory.items[y].data.item_data1[0] == 1) &&
(c->player.inventory.items[y].data.item_data1[1] == 1)) {
equipped_armor = y;
} else if ((c->player.inventory.items[y].data.item_data1[0] == 1) &&
(c->player.inventory.items[y].data.item_data1[1] == 2)) {
equipped_shield = y;
} else if (c->player.inventory.items[y].data.item_data1[0] == 2) {
equipped_mag = y;
}
// else if ((c->player.inventory.items[y].data.item_data1[0] == 1) &&
// (c->player.inventory.items[y].data.item_data1[1] == 1)) {
// equipped_armor = y;
// } else if ((c->player.inventory.items[y].data.item_data1[0] == 1) &&
// (c->player.inventory.items[y].data.item_data1[1] == 2)) {
// equipped_shield = y;
// } else if (c->player.inventory.items[y].data.item_data1[0] == 2) {
// equipped_mag = y;
// }
}
}
+2
View File
@@ -1,5 +1,7 @@
#include "LevelTable.hh"
#include <string.h>
#include <phosg/Filesystem.hh>
#include "Compression.hh"
+4 -2
View File
@@ -43,8 +43,9 @@ LicenseManager::LicenseManager(const std::string& filename) : filename(filename)
auto licenses = load_vector_file<License>(this->filename);
for (const auto& read_license : licenses) {
shared_ptr<License> license(new License(read_license));
uint32_t serial_number = license->serial_number;
this->bb_username_to_license.emplace(license->username, license);
this->serial_number_to_license.emplace(license->serial_number, license);
this->serial_number_to_license.emplace(serial_number, license);
}
} catch (const cannot_open_file&) {
@@ -124,7 +125,8 @@ void LicenseManager::ban_until(uint32_t serial_number, uint64_t end_time) {
void LicenseManager::add(shared_ptr<License> l) {
{
rw_guard g(this->lock, true);
this->serial_number_to_license.emplace(l->serial_number, l);
uint32_t serial_number = l->serial_number;
this->serial_number_to_license.emplace(serial_number, l);
if (l->username[0]) {
this->bb_username_to_license.emplace(l->username, l);
}
+2
View File
@@ -1,5 +1,7 @@
#include "Lobby.hh"
#include <string.h>
#include "SendCommands.hh"
#include "Text.hh"
+2 -6
View File
@@ -299,11 +299,9 @@ void PSOBBEncryption::decrypt(void* vdata, size_t size) {
size >>= 3;
uint32_t* data = reinterpret_cast<uint32_t*>(vdata);
uint32_t eax, ecx, edx, ebx, ebp, esi, edi;
uint32_t edx, ebx, ebp, esi, edi;
edx = 0;
ecx = 0;
eax = 0;
while (edx < size) {
ebx = data[edx];
ebx = ebx ^ this->stream[5];
@@ -337,11 +335,9 @@ void PSOBBEncryption::encrypt(void* vdata, size_t size) {
size >>= 3;
uint8_t* data = reinterpret_cast<uint8_t*>(vdata);
uint32_t eax, ecx, edx, ebx, ebp, esi, edi;
uint32_t edx, ebx, ebp, esi, edi;
edx = 0;
ecx = 0;
eax = 0;
while (edx < size) {
ebx = data[edx];
ebx = ebx ^ this->stream[0];
+7
View File
@@ -1,5 +1,9 @@
#include "PSOProtocol.hh"
#include <stdexcept>
using namespace std;
uint16_t PSOCommandHeader::command(GameVersion version) const {
@@ -13,6 +17,7 @@ uint16_t PSOCommandHeader::command(GameVersion version) const {
case GameVersion::BB:
return reinterpret_cast<const PSOCommandHeaderBB*>(this)->command;
}
throw logic_error("unknown game version");
}
uint16_t PSOCommandHeader::size(GameVersion version) const {
@@ -26,6 +31,7 @@ uint16_t PSOCommandHeader::size(GameVersion version) const {
case GameVersion::BB:
return reinterpret_cast<const PSOCommandHeaderBB*>(this)->size;
}
throw logic_error("unknown game version");
}
uint32_t PSOCommandHeader::flag(GameVersion version) const {
@@ -39,5 +45,6 @@ uint32_t PSOCommandHeader::flag(GameVersion version) const {
case GameVersion::BB:
return reinterpret_cast<const PSOCommandHeaderBB*>(this)->flag;
}
throw logic_error("unknown game version");
}
+3 -1
View File
@@ -1,5 +1,6 @@
#include "Quest.hh"
#include <algorithm>
#include <string>
#include <unordered_map>
#include <phosg/Filesystem.hh>
@@ -330,7 +331,8 @@ QuestIndex::QuestIndex(const char* directory) : directory(directory) {
string full_path = this->directory + "/" + filename;
if (ends_with(filename, ".gba")) {
this->gba_file_contents.emplace(filename, new string(load_file(full_path)));
shared_ptr<string> contents(new string(load_file(full_path)));
this->gba_file_contents.emplace(make_pair(filename, contents));
continue;
}
+2
View File
@@ -3,7 +3,9 @@
#include <stdint.h>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "Version.hh"
+3
View File
@@ -24,7 +24,10 @@ This project is primarily for my own nostalgia. Feel free to peruse if you'd lik
## Usage
Currently this code should build on macOS and Ubuntu. It might build on other Linux flavors, but don't expect it to work on Windows at all.
So, you've read all of the above and you want to try it out? Here's what you do:
- Make sure you have libreadline installed (use Homebrew in macOS, or install libreadline-dev in Linux).
- Build and install phosg (https://github.com/fuzziqersoftware/phosg).
- Run `make`.
- Edit system/config.json to your liking.
+1
View File
@@ -1,6 +1,7 @@
#include "SendCommands.hh"
#include <inttypes.h>
#include <string.h>
#include <memory>
#include <phosg/Filesystem.hh>
+2
View File
@@ -1,5 +1,7 @@
#include "ReceiveSubcommands.hh"
#include <string.h>
#include <memory>
#include <phosg/Strings.hh>
+2
View File
@@ -1,5 +1,7 @@
#include "SendCommands.hh"
#include <string.h>
#include <memory>
#include <phosg/Encoding.hh>
#include <phosg/Random.hh>
+3 -2
View File
@@ -128,7 +128,8 @@ void Server::on_listen_accept(Server::WorkerThread& wt,
struct bufferevent *bev = bufferevent_socket_new(wt.base.get(), fd,
BEV_OPT_CLOSE_ON_FREE | BEV_OPT_THREADSAFE | BEV_OPT_DEFER_CALLBACKS | BEV_OPT_UNLOCK_CALLBACKS);
auto emplace_ret = wt.bev_to_client.emplace(bev, new Client(bev, version, initial_state));
shared_ptr<Client> c(new Client(bev, version, initial_state));
auto emplace_ret = wt.bev_to_client.emplace(make_pair(bev, c));
this->client_count++;
bufferevent_setcb(bev, &WorkerThread::dispatch_on_client_input, NULL,
@@ -231,7 +232,7 @@ void Server::receive_and_process_commands(shared_ptr<Client> c, struct buffereve
new_bytes &= ~(header_size - 1); // only read in multiples of header_size
c->recv_buffer.resize(existing_bytes + new_bytes);
void* recv_ptr = const_cast<char*>(c->recv_buffer.data() + existing_bytes);
if (evbuffer_remove(buf, recv_ptr, new_bytes) != new_bytes) {
if (evbuffer_remove(buf, recv_ptr, new_bytes) != static_cast<ssize_t>(new_bytes)) {
throw runtime_error("some bytes could not be read from the receive buffer");
}