--- a/QTfrontend/game.cpp Tue Dec 04 09:15:55 2012 +0400
+++ b/QTfrontend/game.cpp Tue Dec 04 22:31:22 2012 +0400
@@ -54,28 +54,6 @@
flib_gameconn_destroy(m_conn);
}
-void HWGame::onClientDisconnect()
-{/*
- switch (gameType)
- {
- case gtDemo:
- // for video recording we need demo anyway
- emit HaveRecord(rtNeither, demo);
- break;
- case gtNet:
- emit HaveRecord(rtDemo, demo);
- break;
- default:
- if (gameState == gsInterrupted || gameState == gsHalted)
- emit HaveRecord(rtSave, demo);
- else if (gameState == gsFinished)
- emit HaveRecord(rtDemo, demo);
- else
- emit HaveRecord(rtNeither, demo);
- }*/
- SetGameState(gsStopped);
-}
-
void HWGame::commonConfig()
{
QByteArray buf;
@@ -416,7 +394,7 @@
emit GameStateChanged(state);
if (gameType == gtCampaign)
{
- emit CampStateChanged(1);
+ emit campStateChanged(1);
}
}
@@ -452,7 +430,64 @@
teamfile.setValue("Campaign " + campaign + "/" + varToWrite, varValue);
}
+
+static void HWGame::onChat(void* context, const char *msg, bool teamchat)
+{
+ HWGame * game = (HWGame *) context;
+}
+
+static void HWGame::onConnect(void* context)
+{
+ HWGame * game = (HWGame *) context;
+}
+
+static void HWGame::onDisconnect(void* context, int reason)
+{
+ HWGame * game = (HWGame *) context;
+ /*
+ switch (gameType)
+ {
+ case gtDemo:
+ // for video recording we need demo anyway
+ emit HaveRecord(rtNeither, demo);
+ break;
+ case gtNet:
+ emit HaveRecord(rtDemo, demo);
+ break;
+ default:
+ if (gameState == gsInterrupted || gameState == gsHalted)
+ emit HaveRecord(rtSave, demo);
+ else if (gameState == gsFinished)
+ emit HaveRecord(rtDemo, demo);
+ else
+ emit HaveRecord(rtNeither, demo);
+ }*/
+ game->SetGameState(gsStopped);
+}
+
+static void HWGame::onEngineMessage(void *context, const uint8_t *em, size_t size)
+{
+ HWGame * game = (HWGame *) context;
+}
+
+static void HWGame::onErrorMessage(void* context, const char *msg)
+{
+ HWGame * game = (HWGame *) context;
+}
+
+static void HWGame::onGameRecorded(void *context, const uint8_t *record, size_t size, bool isSavegame)
+{
+ HWGame * game = (HWGame *) context;
+}
+
void HWGame::onEngineStart()
{
+ flib_gameconn_onChat(m_conn, onChat, this);
+ flib_gameconn_onConnect(m_conn, onConnect, this);
+ flib_gameconn_onDisconnect(m_conn, onDisconnect, this);
+ flib_gameconn_onEngineMessage(m_conn, onEngineMessage, this);
+ flib_gameconn_onErrorMessage(m_conn, onErrorMessage, this);
+ flib_gameconn_onGameRecorded(m_conn, onGameRecorded, this);
+
new FrontLibPoller((void (*)(void *))flib_gameconn_tick, m_conn, this);
}
--- a/QTfrontend/game.h Tue Dec 04 09:15:55 2012 +0400
+++ b/QTfrontend/game.h Tue Dec 04 22:31:22 2012 +0400
@@ -70,7 +70,6 @@
protected:
virtual QStringList getArguments();
virtual void onClientRead();
- virtual void onClientDisconnect();
void onEngineStart();
signals:
@@ -81,7 +80,7 @@
void GameStats(char type, const QString & info);
void HaveRecord(RecordType type, const QByteArray & record);
void ErrorMessage(const QString &);
- void CampStateChanged(int);
+ void campStateChanged(int);
public slots:
void FromNet(const QByteArray & msg);
@@ -115,6 +114,13 @@
void SetGameState(GameState state);
void sendCampaignVar(const QByteArray & varToSend);
void writeCampaignVar(const QByteArray &varVal);
+
+ static void onChat(void* context, const char *msg, bool teamchat);
+ static void onConnect(void* context);
+ static void onDisconnect(void* context, int reason);
+ static void onEngineMessage(void *context, const uint8_t *em, size_t size);
+ static void onErrorMessage(void* context, const char *msg);
+ static void onGameRecorded(void *context, const uint8_t *record, size_t size, bool isSavegame);
};
#endif