start on toxic game port

This commit is contained in:
2023-11-25 19:41:55 +01:00
commit 8f02e6b5ee
7 changed files with 281 additions and 0 deletions

39
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.24 FATAL_ERROR)
if (OFF)
add_library(toxic_games STATIC
#./toxic/windows_stripped.h
#./toxic/misc_tools.h
#./toxic/misc_tools.c
./toxic/fake_ncurses.h
./toxic/toxic_patched_utils.h
./toxic/game_base.h
#./toxic/game_base.c
./toxic/game_base_stripped.c
./toxic/game_util.h
./toxic/game_util.c
#./toxic/game_centipede.h
#./toxic/game_centipede.c
./toxic/game_chess.h
./toxic/game_chess.c
#./toxic/game_life.h
#./toxic/game_life.c
#./toxic/game_snake.h
#./toxic/game_snake.c
)
endif()
########################################
add_library(solanaceae_toxic_games
./solanaceae_toxic_games.hpp
./solanaceae_toxic_games.cpp
)
target_link_libraries(solanaceae_toxic_games PUBLIC
solanaceae_tox_contacts
)

View File

@ -0,0 +1,34 @@
#include "./solanaceae_toxic_games.hpp"
ToxicGames::ToxicGames(
Contact3Registry& cr,
ToxI& t,
ToxEventProviderI& tep,
ToxContactModel2& tcm
) :
_cr(cr),
_t(t),
_tep(tep),
_tcm(tcm)
{
// register custom packet handlers
_tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_LOSSLESS_PACKET);
_tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_CUSTOM_PACKET);
_tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_CUSTOM_PRIVATE_PACKET);
}
bool ToxicGames::onToxEvent(const Tox_Event_Friend_Lossless_Packet* e) {
//CUSTOM_PACKET_GAME_INVITE = 160,
//CUSTOM_PACKET_GAME_DATA = 161,
return false;
}
bool ToxicGames::onToxEvent(const Tox_Event_Group_Custom_Packet* e) {
return false;
}
bool ToxicGames::onToxEvent(const Tox_Event_Group_Custom_Private_Packet* e) {
return false;
}

View File

@ -0,0 +1,25 @@
#pragma once
#include <solanaceae/contact/contact_model3.hpp>
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
class ToxicGames : public ToxEventI {
Contact3Registry& _cr;
ToxI& _t;
ToxEventProviderI& _tep;
ToxContactModel2& _tcm;
public:
ToxicGames(
Contact3Registry& cr,
ToxI& t,
ToxEventProviderI& tep,
ToxContactModel2& tcm
);
private: // tox events
bool onToxEvent(const Tox_Event_Friend_Lossless_Packet* e) override;
bool onToxEvent(const Tox_Event_Group_Custom_Packet* e) override;
bool onToxEvent(const Tox_Event_Group_Custom_Private_Packet* e) override;
};