diff --git a/.gitignore b/.gitignore
index 0e1278799..efc014a41 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,9 @@
/server/catchchallenger-server-cli-epoll
/client/catchchallenger
+# generated output
+/tools/map-procedural-generation/dest
+
### Qt ###
# C++ objects and libs
*.so.*
@@ -94,4 +97,4 @@ tools/to-pack/data/windows-x*
# Configurations
/server/server-properties.xml
/client/datapack
-/server/datapack
\ No newline at end of file
+/server/datapack
diff --git a/README.md b/README.md
index 9b317f562..3ebd59d77 100644
--- a/README.md
+++ b/README.md
@@ -6,20 +6,20 @@ http://catchchallenger.first-world.info/
## Description
This game is a MMORPG, Lan game and a single player game. It's mix of pokemon for the RPG part, lineage for the crafting/clan/MMORPG, X3 for the commerce/fabric/industry. With mod possibility, and datapack.
-It's a pixel art game. The work is concentrated on the gameplay/performance/security/creativity/accessibility. The income is to paid the developping and the artwork. The game is fully open source (GPL3).
+It's a pixel art game. The work is concentrated on the gameplay/performance/security/creativity/accessibility. The income is to paid the developing and the artwork. The game is fully open source (GPL3).
-The gameplay have strong team part, but remain interresting in single player. Have clear advantage on 3G/wifi/TOR connexion or into the tiers world.
+The gameplay have strong team part, but remain interesting in single player. Have clear advantage on 3G/wifi/TOR connexion or into the tiers world.
## License
client/tiled/ is extracted version of http://www.mapeditor.org/, https://github.com/bjorn/tiled
libogg and fileopus is extracted from other project
-Interface UI is from buyed template (then under copyright)
+Interface UI is from bought template (then under copyright)
-## Programing
+## Programming
Asynchronous protocol with no influence of internet and server latency. Thread isolation for the important or heavy server task. It can be hosted on ADSL connection.
-SGBD for Qt version: Mysql 5+, SQLite, PostgreSQL 9+. SGBD for epoll version (async to high performance): Mysql 5.5+, PostgreSQL 9+.
+DBMS for Qt version: Mysql 5+, SQLite, PostgreSQL 9+. DBMS for epoll version (async to high performance): Mysql 5.5+, PostgreSQL 9+.
## Prerequisites
@@ -63,9 +63,9 @@ Dependency:
* curl to download datapack via http
### Linux distro
-**Ubuntu**: apt-get install build-essential gcc automake qt5-qmake qt5-default libzstd-dev zlib1g-dev libssl-dev libpq-dev libqt5sql5-psql libqt5websockets5-dev libqt5sql5-sqlite libqt5sql5-mysql qtdeclarative5-dev qtscript5-dev
+**Ubuntu**: apt-get install build-essential gcc automake qt5-qmake libzstd-dev zlib1g-dev libssl-dev libpq-dev libqt5sql5-psql libqt5websockets5-dev libqt5sql5-sqlite libqt5sql5-mysql qtdeclarative5-dev qtscript5-dev
-**Debian stretch**: apt-get install build-essential gcc automake qt5-qmake libzstd-dev zlib1g-dev libssl-dev libpq-dev qttools5-dev qt5-default libqt5sql5-psql libqt5websockets5-dev libqt5sql5-psql libqt5sql5-sqlite libqt5sql5-mysql qtdeclarative5-dev qtscript5-dev
+**Debian stretch**: apt-get install build-essential gcc automake qt5-qmake libzstd-dev zlib1g-dev libssl-dev libpq-dev qttools5-dev libqt5sql5-psql libqt5websockets5-dev libqt5sql5-psql libqt5sql5-sqlite libqt5sql5-mysql qtdeclarative5-dev qtscript5-dev
### Gui server
```sh
@@ -86,7 +86,7 @@ git clone --depth=1 https://github.com/alphaonex86/CatchChallenger-datapack data
### Epoll server (linux only, high performance)
**Ubuntu**: apt-get install libzstd-dev zlib1g-dev libssl-dev libpq-dev
-**Debian stretch**: apt-get install build-essential gcc automake qt5-qmake libzstd-dev zlib1g-dev libssl-dev libpq-dev qttools5-dev qt5-default
+**Debian stretch**: apt-get install build-essential gcc automake qt5-qmake libzstd-dev zlib1g-dev libssl-dev libpq-dev qttools5-dev
```sh
cd server/
@@ -98,7 +98,7 @@ chmod a+x catchchallenger-server-cli-epoll
```
### Client
-**Debian stretch**: apt-get install build-essential gcc automake qt5-qmake libzstd-dev zlib1g-dev libssl-dev libpq-dev qttools5-dev qt5-default qtdeclarative5-dev qtscript5-dev
+**Debian stretch**: apt-get install build-essential gcc automake qt5-qmake libzstd-dev zlib1g-dev libssl-dev libpq-dev qttools5-dev qtdeclarative5-dev qtscript5-dev
```sh
cd client/
@@ -114,7 +114,15 @@ chmod a+x catchchallenger
* The sources of the datapack: https://github.com/alphaonex86/CatchChallenger-datapack
* The sources of the site: https://github.com/alphaonex86/CatchChallenger-site
-# Hardware
-You need CPU with support of unaligned access on 8/16/32Bits for the server at least (plan to support all CPU)
-
-The server is actually 10-20MB of memory (1MB measured by massif) and 2KB by player
+# Hardware server
+Tested on physical hardware:
+* Intel i486DX2-66 at 66Mhz for x86
+* Geode LX800 (i486/i586 like) at 500MHz for x86
+* RISC-V (without SIMD)
+* MIPS2 big endian a 200MHz
+* RPI1 at 700MHz 32-bit for ARM11
+* Pentium 3 at 750MHz for x86
+Without problem with 200 players.
+And of course more modern CPU like AMD Ryzen 9 7950X3D 16-Core Processor in x86_64, all qemu arch
+
+The server is actually 10-20MB of memory (3MB measured by massif) and 1-4KB by player
diff --git a/THANKS b/THANKS
deleted file mode 100644
index 6ffa4606a..000000000
--- a/THANKS
+++ /dev/null
@@ -1,4 +0,0 @@
-Special thanks for this project to:
-The people of #qt-fr of freenode
-vlc dev
-
diff --git a/client/.qmake.stash b/client/.qmake.stash
deleted file mode 100644
index bcd0a9488..000000000
--- a/client/.qmake.stash
+++ /dev/null
@@ -1,28 +0,0 @@
-QMAKE_CXX.QT_COMPILER_STDCXX = 201402L
-QMAKE_CXX.QMAKE_CLANG_MAJOR_VERSION = 8
-QMAKE_CXX.QMAKE_CLANG_MINOR_VERSION = 0
-QMAKE_CXX.QMAKE_CLANG_PATCH_VERSION = 2
-QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 4
-QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 2
-QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 1
-QMAKE_CXX.COMPILER_MACROS = \
- QT_COMPILER_STDCXX \
- QMAKE_CLANG_MAJOR_VERSION \
- QMAKE_CLANG_MINOR_VERSION \
- QMAKE_CLANG_PATCH_VERSION \
- QMAKE_GCC_MAJOR_VERSION \
- QMAKE_GCC_MINOR_VERSION \
- QMAKE_GCC_PATCH_VERSION
-QMAKE_CXX.INCDIRS = \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/sysroot/usr/include/arm-linux-androideabi \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/sources/cxx-stl/llvm-libc++/include \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/sources/android/support/include \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/sources/cxx-stl/llvm-libc++abi/include \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.2/include \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/sysroot/usr/include
-QMAKE_CXX.LIBDIRS = \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.2 \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/8.0.2/lib/linux/arm \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x/armv7-a \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/lib/armv7-a \
- /mnt/data/perso/pc-virtuel/android-qtcreator/opt/android-sdk/ndk-r19c/platforms/android-16/arch-arm/usr/lib
diff --git a/client/android-sources/build.sh b/client/android-sources/build.sh
deleted file mode 100755
index 1632b5b11..000000000
--- a/client/android-sources/build.sh
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-DEBUG=0
-if [ $DEBUG -eq 0 ]
-then
- mkdir /home/user/build
- cd /home/user/build
- mkdir /home/user/build/dist/
- #qmake -r /home/user/src/client/catchchallenger.pro CONFIG+=debug ANDROID_EXTRA_LIBS+=$ANDROID_DEV/lib/libcrypto.so ANDROID_EXTRA_LIBS+=$ANDROID_DEV/lib/libssl.so QMAKE_CFLAGS+=-funwind-tables QMAKE_CXXFLAGS+=-funwind-tables
- qmake -r /home/user/src/client/catchchallenger.pro ANDROID_EXTRA_LIBS+=$ANDROID_DEV/lib/libcrypto.so ANDROID_EXTRA_LIBS+=$ANDROID_DEV/lib/libssl.so
- make -j17
- if [ $? -ne 0 ]
- then
- make clean
- make
- exit
- fi
- make install INSTALL_ROOT=/home/user/build/dist/
- #cp -r /home/user/src/client/android-sources/* /home/user/build/dist/
- #make install INSTALL_ROOT=/home/user/dist/
- cd /home/user/build/
- #androiddeployqt --input android-libcatchchallenger.so-deployment-settings.json --output dist/ --android-platform 28 --deployment bundled --gradle --debug
- androiddeployqt --input android-libcatchchallenger.so-deployment-settings.json --output dist/ --android-platform 28 --deployment bundled --gradle --release
-else
- mkdir /home/user/build
- cd /home/user/build
- mkdir /home/user/build/dist/
- qmake -r /home/user/src/client/catchchallenger.pro CONFIG+=debug ANDROID_EXTRA_LIBS+=$ANDROID_DEV/lib/libcrypto.so ANDROID_EXTRA_LIBS+=$ANDROID_DEV/lib/libssl.so QMAKE_CFLAGS+=-funwind-tables QMAKE_CXXFLAGS+=-funwind-tables
- make -j17
- if [ $? -ne 0 ]
- then
- make clean
- make
- exit
- fi
- make install INSTALL_ROOT=/home/user/build/dist/
- if [ $? -ne 0 ]
- then
- exit
- fi
- cd /home/user/build/
- androiddeployqt --input android-libcatchchallenger.so-deployment-settings.json --output dist/ --android-platform 28 --deployment bundled --gradle --debug
-fi
diff --git a/client/android-sources/res/mipmap-xhdpi/icon.png b/client/android-sources/res/mipmap-xhdpi/icon.png
deleted file mode 100644
index 9b5ec11d7..000000000
Binary files a/client/android-sources/res/mipmap-xhdpi/icon.png and /dev/null differ
diff --git a/client/android-sources/res/mipmap-xxhdpi/icon.png b/client/android-sources/res/mipmap-xxhdpi/icon.png
deleted file mode 100644
index b265e863c..000000000
Binary files a/client/android-sources/res/mipmap-xxhdpi/icon.png and /dev/null differ
diff --git a/client/android-sources/res/mipmap-xxxhdpi/icon.png b/client/android-sources/res/mipmap-xxxhdpi/icon.png
deleted file mode 100644
index ef0222353..000000000
Binary files a/client/android-sources/res/mipmap-xxxhdpi/icon.png and /dev/null differ
diff --git a/client/catchchallenger-2.2.0.0.recipe b/client/catchchallenger-2.2.0.0.recipe
index 4a75a0e96..71b425cec 100644
--- a/client/catchchallenger-2.2.0.0.recipe
+++ b/client/catchchallenger-2.2.0.0.recipe
@@ -1,6 +1,6 @@
SUMMARY="Game MMORPG/single player game. You can fight, farming, crafting, trading"
DESCRIPTION="This game is a independent MMORPG or a single player game."
-HOMEPAGE="https://catchchallenger.first-world.info/"
+HOMEPAGE="https://catchchallenger.herman-brule.com/"
COPYRIGHT="2011-2019 BRULE Herman Jacques Roger (alpha_one_x86)"
LICENSE="GNU GPL v3"
REVISION="1"
diff --git a/client/catchchallenger.pro b/client/catchchallenger.pro
index 4e3ea5d3b..11980662b 100644
--- a/client/catchchallenger.pro
+++ b/client/catchchallenger.pro
@@ -1,9 +1,5 @@
-include(qtopengl/client.pri)
-include(../general/general.pri)
-include(qt/qt.pri)
-
-linux:QMAKE_CXXFLAGS+="-Wno-deprecated-declarations"
-linux:QMAKE_CFLAGS+="-Wno-deprecated-declarations"
-
-DEFINES += OPENGL CATCHCHALLENGER_CACHE_HPS
-TARGET = catchchallenger
+include(qtopengl/catchchallenger-qtopengl.pro)
+#DEFINES += DEBUG_PROTOCOLPARSING_RAW_NETWORK
+#DEFINES += DEBUG_MESSAGE_CLIENT_SQL
+DEFINES += CATCHCHALLENGER_CACHE_HPS
+linux:QMAKE_LFLAGS += -fuse-ld=mold
diff --git a/client/cc-API-client.png b/client/cc-API-client.png
new file mode 100644
index 000000000..c5e51c73c
Binary files /dev/null and b/client/cc-API-client.png differ
diff --git a/client/cpu/.qmake.stash b/client/cpu/.qmake.stash
deleted file mode 100755
index 40886cadd..000000000
--- a/client/cpu/.qmake.stash
+++ /dev/null
@@ -1,15 +0,0 @@
-QMAKE_CXX.QT_COMPILER_STDCXX = 199711L
-QMAKE_CXX.QMAKE_CLANG_MAJOR_VERSION = 6
-QMAKE_CXX.QMAKE_CLANG_MINOR_VERSION = 0
-QMAKE_CXX.QMAKE_CLANG_PATCH_VERSION = 1
-QMAKE_CXX.QMAKE_GCC_MAJOR_VERSION = 4
-QMAKE_CXX.QMAKE_GCC_MINOR_VERSION = 2
-QMAKE_CXX.QMAKE_GCC_PATCH_VERSION = 1
-QMAKE_CXX.COMPILER_MACROS = \
- QT_COMPILER_STDCXX \
- QMAKE_CLANG_MAJOR_VERSION \
- QMAKE_CLANG_MINOR_VERSION \
- QMAKE_CLANG_PATCH_VERSION \
- QMAKE_GCC_MAJOR_VERSION \
- QMAKE_GCC_MINOR_VERSION \
- QMAKE_GCC_PATCH_VERSION
diff --git a/client/cpu/catchchallenger.pro b/client/cpu/catchchallenger.pro
deleted file mode 100644
index 718dab917..000000000
--- a/client/cpu/catchchallenger.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-include(../qt/client.pri)
-include(../../general/general.pri)
-include(../qt/multi.pri)
-
-!contains(DEFINES, NOSINGLEPLAYER) {
- include(../qt/solo.pri)
- include(../../server/catchchallenger-server-qt.pri)
- INCLUDEPATH += -I/usr/include/
-}
-
-TARGET = catchchallenger
-
-SOURCES += $$PWD/main.cpp
diff --git a/client/cpu/languages/en/specific.ts b/client/cpu/languages/en/specific.ts
deleted file mode 100644
index f5e88b58a..000000000
--- a/client/cpu/languages/en/specific.ts
+++ /dev/null
@@ -1,477 +0,0 @@
-
-
-
-
- AddOrEditServer
-
-
- Save
-
-
-
-
- Error
-
-
-
-
- The name can't be "internal"
-
-
-
-
- AddServer
-
-
- Add server
-
-
-
-
- Server:
-
-
-
-
- www.server.com
-
-
-
-
- Name:
-
-
-
-
- Name
-
-
-
-
- Proxy:
-
-
-
-
- proxy ip
-
-
-
-
- Ok
-
-
-
-
- MainWindow
-
-
- Solo
-
-
-
-
- Multiplayers
-
-
-
-
- <a href="http://catchchallenger.first-world.info/"><span style="color:#FFF;text-decoration:none;">CatchChallenger</span></a> <!-- (Don't remove please) -->
-
-
-
-
- Ultimate key
-
-
-
-
-
- <html><head/><body><p align="center"><span style=" font-size:12pt; color:#a0a0a0;">Empty</span></p></body></html>
-
-
-
-
- Loading the server list...
-
-
-
-
- Loading the servers list...
-
-
-
-
- Select
-
-
-
-
- Add
-
-
-
-
- Edit
-
-
-
-
- Remove
-
-
-
-
- Refresh
-
-
-
-
-
- Back
-
-
-
-
- Manage datapacks
-
-
-
-
- Delete
-
-
-
-
- Login
-
-
-
-
- Password:
-
-
-
-
- Show the password
-
-
-
-
- Remember the password
-
-
-
-
- <a href="http://catchchallenger.first-world.info/"><span style="text-decoration:underline;color:#0057ae;">Web site</span></a>
-
-
-
-
- <a href="http://catchchallenger.first-world.info/register.html"><span style="text-decoration:underline;color:#0057ae;">Register</span></a>
-
-
-
-
- Ok
-
-
-
-
- Cancel
-
-
-
-
- Copy of %1
-
-
-
-
-
- Empty
-
-
-
-
- Last connexion: %1
-
-
-
-
- Custom
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Error
-
-
-
-
- The key is wrong
-
-
-
-
-
- The host seam don't be a valid hostname or ip
-
-
-
-
-
- The name is already taken
-
-
-
-
- Internal error
-
-
-
-
- Internal error: Can't select this server
-
-
-
-
- <a href="%1"><span style="text-decoration:underline;color:#0057ae;">Register</span></a>
-
-
-
-
- <a href="%1"><span style="text-decoration:underline;color:#0057ae;">Web site</span></a>
-
-
-
-
- Disconnected
-
-
-
-
- Disconnected by the reason: %1
-
-
-
-
- Your password need to be at minimum of 6 characters
-
-
-
-
- Your password is into the most common password in the world, too easy to crack dude! Change it!
-
-
-
-
- Your login need to be at minimum of 3 characters
-
-
-
-
- Your login can't be same as your login
-
-
-
-
- Not able to create the folder %1
-
-
-
-
- Quit
-
-
-
-
- The server have closed the connexion
-
-
-
-
- on %1
-
-
-
-
-
-
-
-
-
-
-
-
- Connection closed
-
-
-
-
- Connection closed by the server
-
-
-
-
- Connection refused by the server
-
-
-
-
- Socket time out, server too long
-
-
-
-
- The host address was not found
-
-
-
-
- The socket operation failed because the application lacked the required privileges
-
-
-
-
- An error occurred with the network (Connection refused on game server?)
-
-
-
-
- The local system ran out of resources
-
-
-
-
- The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support)
-
-
-
-
- The SSL/TLS handshake failed, so the connection was closed
-
-
-
-
- Connection error
-
-
-
-
- Connection error: %1
-
-
-
-
-
-
-
- Unknown
-
-
-
-
- Internal datapack
-
-
-
-
- Get from %1
-
-
-
-
- port %1
-
-
-
-
- Author: %1
-
-
-
-
- Are you sure?
-
-
-
-
- Are you sure delete the datapack? This operation is not reversible.
-
-
-
-
- Remove the datapack path is not completed. Try after restarting the application
-
-
-
-
- Get server list failed: %1
-
-
-
-
- Get server list redirection denied to: %1
-
-
-
-
- Unable to load internal value
-
-
-
-
-
- The engine is closed due to: %1
-
-
-
-
- Unable to save internal value at game stopping
-
-
-
-
-
- No main code detected into the current datapack
-
-
-
-
-
- Latest news:
-
-
-
-
-
-
-
-
- Ok
-
-
-
-
- Ok (%1)
-
-
-
-
diff --git a/client/cpu/languages/fr/specific.ts b/client/cpu/languages/fr/specific.ts
deleted file mode 100644
index a0769c04d..000000000
--- a/client/cpu/languages/fr/specific.ts
+++ /dev/null
@@ -1,478 +0,0 @@
-
-
-
-
- AddOrEditServer
-
-
- Save
-
-
-
-
- Error
- Erreur
-
-
-
- The name can't be "internal"
- Le nom de peu être "internal"
-
-
-
- AddServer
-
-
- Add server
- Ajouter un serveur
-
-
-
- Server:
- Serveur:
-
-
-
- www.server.com
- www.serveur.com
-
-
-
- Name:
- Nom:
-
-
-
- Name
- Nom
-
-
-
- Proxy:
-
-
-
-
- proxy ip
- ip du proxy
-
-
-
- Ok
- Ok
-
-
-
- MainWindow
-
-
- Solo
- Solo
-
-
-
- Multiplayers
- Multi joueurs
-
-
-
- <a href="http://catchchallenger.first-world.info/"><span style="color:#FFF;text-decoration:none;">CatchChallenger</span></a> <!-- (Don't remove please) -->
- Merci de ne pas supprimer ce lien
- <a href="http://catchchallenger.first-world.info/"><span style="color:#FFF;text-decoration:none;">CatchChallenger</span></a> <!-- (Don't remove please) -->
-
-
-
- Ultimate key
-
-
-
-
-
- <html><head/><body><p align="center"><span style=" font-size:12pt; color:#a0a0a0;">Empty</span></p></body></html>
- <html><head/><body><p align="center"><span style=" font-size:12pt; color:#a0a0a0;">Vide</span></p></body></html>
-
-
-
- Loading the server list...
- Chargement de la liste des servers...
-
-
-
- Loading the servers list...
- Chargement de la liste des serveurs...
-
-
-
- Select
- Selectionner
-
-
-
- Add
- Ajouter
-
-
-
- Edit
-
-
-
-
- Remove
- Supprimer
-
-
-
- Refresh
- Refraichir
-
-
-
-
- Back
- Retour
-
-
-
- Manage datapacks
- Gestion des datapacks
-
-
-
- Delete
- Supprimer
-
-
-
- Login
- Login
-
-
-
- Password:
- Mot de passe:
-
-
-
- Show the password
-
-
-
-
- Remember the password
- Sauvegarder le mot de passe
-
-
-
- <a href="http://catchchallenger.first-world.info/"><span style="text-decoration:underline;color:#0057ae;">Web site</span></a>
- <a href="http://catchchallenger.first-world.info/"><span style="text-decoration:underline;color:#0057ae;">Site web</span></a>
-
-
-
- <a href="http://catchchallenger.first-world.info/register.html"><span style="text-decoration:underline;color:#0057ae;">Register</span></a>
- <a href="http://catchchallenger.first-world.info/register.html"><span style="text-decoration:underline;color:#0057ae;">S'enregister</span></a>
-
-
-
- Ok
- Ok
-
-
-
- Cancel
- Annuler
-
-
-
- Copy of %1
- Copie de %1
-
-
-
-
- Empty
- Vide
-
-
-
- Last connexion: %1
- Derniére connexion: %1
-
-
-
- Custom
- Personnalisé
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Error
- Erreur
-
-
-
- The key is wrong
-
-
-
-
-
- The host seam don't be a valid hostname or ip
- Le nom d'hote ne semble pas valide ou ne semble pas être une ip
-
-
-
-
- The name is already taken
- Le nom est déjà pris
-
-
-
- Internal error
- Erreur interne
-
-
-
- Internal error: Can't select this server
- Erreur interne: Impossible de sélectionner le serveur
-
-
-
- <a href="%1"><span style="text-decoration:underline;color:#0057ae;">Register</span></a>
- <a href="%1"><span style="text-decoration:underline;color:#0057ae;">S'enregistrer</span></a>
-
-
-
- <a href="%1"><span style="text-decoration:underline;color:#0057ae;">Web site</span></a>
- <a href="%1"><span style="text-decoration:underline;color:#0057ae;">Site web</span></a>
-
-
-
- Disconnected
- Déconnecté
-
-
-
- Disconnected by the reason: %1
- Déconnecté par la raison: %1
-
-
-
- Your password need to be at minimum of 6 characters
- Votre mots de passe doit faire au moins 6 caractéres
-
-
-
- Your password is into the most common password in the world, too easy to crack dude! Change it!
-
-
-
-
- Your login need to be at minimum of 3 characters
- Votre login doit faire au moins 3 caratéres
-
-
-
- Your login can't be same as your login
-
-
-
-
- Not able to create the folder %1
- Impossible de créé le dossier %1
-
-
-
- Quit
-
-
-
-
- The server have closed the connexion
-
-
-
-
- on %1
-
-
-
-
-
-
-
-
-
-
-
-
- Connection closed
- Connexion fermé
-
-
-
- Connection closed by the server
- Connexion fermé par le serveur
-
-
-
- Connection refused by the server
- Connexion refusé par le serveur
-
-
-
- Socket time out, server too long
- Socket délais dépassé, server trop long
-
-
-
- The host address was not found
-
-
-
-
- The socket operation failed because the application lacked the required privileges
-
-
-
-
- An error occurred with the network (Connection refused on game server?)
-
-
-
-
- The local system ran out of resources
- Le systéme est à cour de ressources
-
-
-
- The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support)
- L'operation sur le socket n'est pas supporté par l'OS (comme le manque du support de l'IPv6)
-
-
-
- The SSL/TLS handshake failed, so the connection was closed
- La négociation SSL/TLS à échoué, donc la connexion à été fermé
-
-
-
- Connection error
- Erreur de connexion
-
-
-
- Connection error: %1
- Erreur de connexion: %1
-
-
-
-
-
-
- Unknown
- Inconnu
-
-
-
- Internal datapack
- Datapack interne
-
-
-
- Get from %1
- Obtenu depuis %1
-
-
-
- port %1
- port %1
-
-
-
- Author: %1
- Auteur: %1
-
-
-
- Are you sure?
- Êtes vous sure?
-
-
-
- Are you sure delete the datapack? This operation is not reversible.
- Êtes vous sur de vouloir supprimer le datapack? Cette operation n'est pas réversible.
-
-
-
- Remove the datapack path is not completed. Try after restarting the application
- La suppression du datapack n'est pas compléte; Essayez aprés avoir redémarré l'application
-
-
-
- Get server list failed: %1
- Otention de la liste du serveur: %1
-
-
-
- Get server list redirection denied to: %1
- Obtention de la liste du serveur interdite: %1
-
-
-
- Unable to load internal value
- Impossible de charger une valeur interne
-
-
-
-
- The engine is closed due to: %1
- Le moteur est fermé à cause de: %1
-
-
-
- Unable to save internal value at game stopping
- Impossible de sauvegarder des valeurs interne à l'arret du jeu
-
-
-
-
- No main code detected into the current datapack
-
-
-
-
-
- Latest news:
- Derniéres news:
-
-
-
-
-
-
-
- Ok
- Ok
-
-
-
- Ok (%1)
- Ok (%1)
-
-
-
diff --git a/client/cpu/main.cpp b/client/cpu/main.cpp
deleted file mode 100644
index 54789f846..000000000
--- a/client/cpu/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-#include
-#include "../qt/LanguagesSelect.h"
-#include "../qt/ScreenTransition.h"
-#include "../qt/LocalListener.h"
-#include "../../general/base/FacilityLibGeneral.h"
-//#include "mainwindow.h"
-#include
-#include
-#include
-#include
-#include "../qt/Options.h"
-#include "../qt/QtDatapackChecksum.h"
-
-int main(int argc, char *argv[])
-{
- QApplication a(argc, argv);
- a.setApplicationName("client");
- a.setOrganizationName("CatchChallenger");
- a.setStyle(QStyleFactory::create("Fusion"));
-
- if(argc<1)
- {
- std::cerr << "argc<1: wrong arg count" << std::endl;
- return EXIT_FAILURE;
- }
- CatchChallenger::FacilityLibGeneral::applicationDirPath=argv[0];
-
- QFont font("Comic Sans MS");
- font.setStyleHint(QFont::Monospace);
- //font.setBold(true);
- QApplication::setFont(font);
-
- LocalListener localListener;
- const QStringList &arguments=QCoreApplication::arguments();
- if(arguments.size()==2 && arguments.last()=="quit")
- {
- localListener.quitAllRunningInstance();
- return 0;
- }
- else
- {
- if(!localListener.tryListen())
- return 0;
- }
-
- //QFontDatabase::addApplicationFont(":/fonts/komika_font.ttf");
-
- LanguagesSelect::languagesSelect=new LanguagesSelect();
- /*MainWindow w;
- if(w.toQuit)
- return 523;
- w.show();*/
- Options::options.loadVar();
-
- ScreenTransition s;
- s.setWindowTitle(QObject::tr("CatchChallenger loading..."));
- s.setMinimumSize(QSize(320,240));
- s.showMaximized();
- QIcon icon;
- icon.addFile(":/CC/images/catchchallenger.png", QSize(), QIcon::Normal, QIcon::Off);
- s.setWindowIcon(icon);
- s.show();
- /*LoadingScreen l;
- l.show();*/
- QtDatapackClientLoader::datapackLoader=new QtDatapackClientLoader();
- const auto returnCode=a.exec();
- /*if(w.toQuit)
- return 523;
- else
- return returnCode;*/
- delete QtDatapackClientLoader::datapackLoader;
- #if ! defined(QT_NO_EMIT) && ! defined(EPOLLCATCHCHALLENGERSERVER) && !defined(NOTHREADS)
- CatchChallenger::QtDatapackChecksum::thread.quit();
- CatchChallenger::QtDatapackChecksum::thread.wait();
- #endif
- return returnCode;
-}
diff --git a/client/cpu/mainwindow.cpp b/client/cpu/mainwindow.cpp
deleted file mode 100644
index 479e0293e..000000000
--- a/client/cpu/mainwindow.cpp
+++ /dev/null
@@ -1,1578 +0,0 @@
-#include "mainwindow.h"
-#include "AddServer.h"
-#include "ui_mainwindow.h"
-#include "../qt/InternetUpdater.h"
-#include "../qt/BlacklistPassword.h"
-#include "../../general/base/CommonSettingsCommon.h"
-#include "../../general/base/CommonSettingsServer.h"
-#include "../qt/Ultimate.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "AskKey.h"
-
-#include "../../general/base/GeneralVariable.h"
-#include "../../general/base/Version.h"
-#include "../qt/PlatformMacro.h"
-#include "../qt/ClientVariable.h"
-
-#ifdef Q_CC_GNU
-//this next header is needed to change file time/date under gcc
-#include
-#include
-#include
-#endif
-
-#ifdef __linux__
-#include
-#include
-#include
-#include
-#endif
-
-#include "../qt/render/MapVisualiserPlayer.h"
-#include "../../general/base/FacilityLib.h"
-#include "../../general/base/FacilityLibGeneral.h"
-#include "../../general/base/CommonSettingsCommon.h"
-#include "../qt/LanguagesSelect.h"
-#include "../qt/Api_client_real.h"
-#include "../qt/Api_client_virtual.h"
-#include "../qt/SslCert.h"
-
-MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- toQuit(false),
- ui(new Ui::MainWindow)
- #ifndef CATCHCHALLENGER_NOAUDIO
- ,buffer(&data)
- #endif
-{
- qDebug() << "QStandardPaths::writableLocation(QStandardPaths::DataLocation)" << QStandardPaths::writableLocation(QStandardPaths::DataLocation);
- serverMode=ServerMode_None;
- qRegisterMetaType("QAbstractSocket::SocketError");
- qRegisterMetaType("CatchChallenger::Chat_type");
- qRegisterMetaType("CatchChallenger::Player_type");
- qRegisterMetaType("QAbstractSocket::SocketError");
- qRegisterMetaType("CatchChallenger::Chat_type");
- //qRegisterMetaType("QAbstractSocket::SocketState");-> bug [Fatal] QMetaType::registerType: Binary compatibility break -- Size mismatch for type 'QAbstractSocket::SocketState' [1062]. Previously registered size 1, now registering size 4.
- qRegisterMetaType("CatchChallenger::Player_private_and_public_informations");
- qRegisterMetaType("CatchChallenger::Player_public_informations");
- qRegisterMetaType("CatchChallenger::Direction");
- qRegisterMetaType >("QList");
-
- socket=NULL;
- #ifndef NOTCPSOCKET
- realSslSocket=NULL;
- #endif
- #ifndef NOWEBSOCKET
- realWebSocket=NULL;
- #endif
- #ifndef NOSINGLEPLAYER
- internalServer=NULL;
- #endif
- client=NULL;
- spacer=new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Expanding);
- spacerServer=new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Expanding);
- ui->setupUi(this);
- ui->update->setVisible(false);
- if(settings.contains("news"))
- {
- ui->news->setVisible(true);
- ui->news->setText(settings.value("news").toString());
- }
- else
- ui->news->setVisible(false);
- ui->stackedWidget->setCurrentWidget(ui->mode);
- ui->warning->setVisible(false);
- ui->server_refresh->setEnabled(true);
- baseWindow=new CatchChallenger::BaseWindow();
- ui->stackedWidget->addWidget(baseWindow);
- /*socket==NULL here if(!connect(socket,static_cast(&CatchChallenger::ConnectedSocket::error),this,&MainWindow::error,Qt::QueuedConnection))
- abort();*/
- if(!connect(baseWindow,&CatchChallenger::BaseWindow::newError,this,&MainWindow::newError,Qt::QueuedConnection))
- abort();
- //connect(baseWindow, &CatchChallenger::BaseWindow::needQuit, this,&MainWindow::needQuit);
- if(!connect(&updateTheOkButtonTimer,&QTimer::timeout,this,&MainWindow::updateTheOkButton))
- abort();
-
- /*stopFlood.setSingleShot(false);
- stopFlood.start(1500);
- numberForFlood=0;*/
- updateTheOkButtonTimer.setSingleShot(false);
- updateTheOkButtonTimer.start(1000);
- haveShowDisconnectionReason=false;
- completer=NULL;
-
- stateChanged(QAbstractSocket::UnconnectedState);
-
- setWindowTitle(QStringLiteral("CatchChallenger Ultimate"));
-
- #ifndef CATCHCHALLENGER_NOAUDIO
- // Create a new Media
- {
- player=NULL;
- const std::string &soundFile=QCoreApplication::applicationDirPath().toStdString()+CATCHCHALLENGER_CLIENT_MUSIC_LOADING;
- struct stat sb;
- if(stat(soundFile.c_str(),&sb)==0)
- {
- player = new QAudioOutput(Audio::audio.format(), this);
- if(Audio::decodeOpus(soundFile,data))
- {
- buffer.open(QBuffer::ReadOnly);
- buffer.seek(0);
- player->start(&buffer);
-
- Audio::audio.addPlayer(player);
- }
- else
- {
- delete player;
- player=NULL;
- }
- }
- }
- #endif
- if(!connect(baseWindow,&CatchChallenger::BaseWindow::gameIsLoaded,this,&MainWindow::gameIsLoaded))
- abort();
- #ifdef CATCHCHALLENGER_GITCOMMIT
- ui->version->setText(QString::fromStdString(CatchChallenger::Version::str)+QStringLiteral(" - ")+QStringLiteral(CATCHCHALLENGER_GITCOMMIT));
- #else
- ui->version->setText(QString::fromStdString(CatchChallenger::Version::str));
- #endif
-
- QSettings keySettings;
- if(keySettings.contains(QStringLiteral("key")))
- {
- if(Ultimate::ultimate.setKey(keySettings.value("key").toString().toStdString()))
- ui->UltimateKey->hide();
- }
-}
-
-MainWindow::~MainWindow()
-{
- #ifndef CATCHCHALLENGER_NOAUDIO
- if(player!=NULL)
- {
- player->stop();
- buffer.close();
- Audio::audio.removePlayer(player);
- delete player;
- player=NULL;
- }
- #endif
- if(baseWindow!=NULL)
- {
- baseWindow->deleteLater();
- baseWindow=NULL;
- }
- if(completer!=NULL)
- {
- delete completer;
- completer=NULL;
- }
- if(client!=NULL)
- {
- delete client;
- client=NULL;
- }
- /*if(socket!=NULL)
- {
- socket->disconnectFromHost();
- socket->abort();
- delete socket;
- socket=NULL;
- }*/
- delete ui;
-}
-
-//MS-Windows don't support show modal input into the contructor, then move out it
-bool MainWindow::askForUltimateCopy()
-{
- //after all to prevent not initialised pointer
- AskKey askKey(this);
- askKey.exec();
- QString key=askKey.key();
- if(key.isEmpty())
- {
- //Windows crash: QCoreApplication::quit();->do crash under windows
- std::cout << "key.isEmpty() for ultimate version: " << std::string(__FILE__) << ":" << std::to_string(__LINE__) << std::endl;
- return false;
- }
- {
- if(Ultimate::ultimate.setKey(key.toStdString()))
- {
- ui->UltimateKey->hide();
- QSettings keySettings;
- keySettings.setValue("key",key);
- }
- else
- QMessageBox::critical(this,tr("Error"),tr("The key is wrong"));
- }
- return false;
-}
-
-void MainWindow::closeEvent(QCloseEvent *event)
-{
- #ifndef CATCHCHALLENGER_NOAUDIO
- if(player!=NULL)
- {
- buffer.close();
- player->stop();
- delete player;
- player=NULL;
- }
- #endif
- event->ignore();
- hide();
- if(socket!=NULL
- #ifndef NOSINGLEPLAYER
- || internalServer!=NULL
- #endif
- )
- {
- #ifndef NOSINGLEPLAYER
- if(internalServer!=NULL)
- {
- if(internalServer->isListen())
- internalServer->stop();
- else
- QCoreApplication::quit();
- }
- else
- QCoreApplication::quit();
- #endif
- if(socket!=NULL)
- {
- socket->disconnectFromHost();
- if(socket!=NULL)
- socket->abort();
- }
- }
- else
- QCoreApplication::quit();
-}
-
-void MainWindow::resetAll()
-{
- #ifndef CATCHCHALLENGER_NOAUDIO
- if(player!=NULL)
- player->start();
- #endif
- if(client!=NULL)
- {
- client->resetAll();
- //client->deleteLater();
- client=NULL;
- }
- if(completer!=NULL)
- {
- delete completer;
- completer=NULL;
- }
- if(baseWindow!=NULL)
- baseWindow->resetAll();
- setWindowTitle(QStringLiteral("CatchChallenger Ultimate"));
- switch(serverMode)
- {
- case ServerMode_Internal:
- #ifndef NOSINGLEPLAYER
- ui->stackedWidget->setCurrentWidget(solowindow);
- /* do just at game starting
- *if(internalServer!=NULL)
- {
- internalServer->stop();
- internalServer->deleteLater();
- internalServer=NULL;
- }*/
- saveTime();
- #endif
- break;
- case ServerMode_Remote:
- ui->stackedWidget->setCurrentWidget(ui->poolServersList);
- break;
- default:
- ui->stackedWidget->setCurrentWidget(ui->mode);
- break;
- }
- if(socket!=NULL)
- {
- socket->disconnectFromHost();
- //can be above !=NULL but here ==NULL
- if(socket!=NULL)
- socket->abort();
- }
- lastServer.clear();
- if(ui->lineEditLogin->text().isEmpty())
- ui->lineEditLogin->setFocus();
- else if(ui->lineEditPass->text().isEmpty())
- ui->lineEditPass->setFocus();
- else
- ui->pushButtonTryLogin->setFocus();
- //stateChanged(QAbstractSocket::UnconnectedState);//don't call here, else infinity rescursive call
-}
-
-#ifndef __EMSCRIPTEN__
-void MainWindow::sslErrors(const QList &errors)
-{
- haveShowDisconnectionReason=true;
- QStringList sslErrors;
- int index=0;
- while(indexdisconnectFromHost();*/
-}
-#endif
-
-void MainWindow::disconnected(std::string reason)
-{
- QMessageBox::information(this,tr("Disconnected"),tr("Disconnected by the reason: %1").arg(QString::fromStdString(reason)));
- /*if(serverConnexion.contains(selectedServer))
- lastServerIsKick[serverConnexion.value(selectedServer)->host]=true;*/
- haveShowDisconnectionReason=true;
- resetAll();
-}
-
-void MainWindow::changeEvent(QEvent *e)
-{
- QMainWindow::changeEvent(e);
- switch (e->type()) {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void MainWindow::on_lineEditLogin_returnPressed()
-{
- if(ui->lineEditPass->text().isEmpty())
- ui->lineEditPass->setFocus();
- else
- on_pushButtonTryLogin_clicked();
-}
-
-void MainWindow::on_lineEditPass_returnPressed()
-{
- on_pushButtonTryLogin_clicked();
-}
-
-void MainWindow::on_pushButtonTryLogin_clicked()
-{
- /*if(selectedServer==NULL)
- {
- qDebug() << "selectedServer==NULL, fix it!";
- abort();
- }
- if(!serverConnexion.contains(selectedServer))
- {
- qDebug() << "!serverConnexion.contains(selectedServer)";
- abort();
- }*/
- if(!ui->pushButtonTryLogin->isEnabled())
- return;
- if(ui->lineEditPass->text().size()<6)
- {
- QMessageBox::warning(this,tr("Error"),tr("Your password need to be at minimum of 6 characters"));
- return;
- }
- {
- std::string pass=ui->lineEditPass->text().toStdString();
- std::transform(pass.begin(), pass.end(), pass.begin(), ::tolower);
- unsigned int index=0;
- while(indexlineEditLogin->text().size()<3)
- {
- QMessageBox::warning(this,tr("Error"),tr("Your login need to be at minimum of 3 characters"));
- return;
- }
- if(ui->lineEditPass->text()==ui->lineEditLogin->text())
- {
- QMessageBox::warning(this,tr("Error"),tr("Your login can't be same as your login"));
- return;
- }
- serverMode=ServerMode_Remote;
- /*ConnexionInfo * const selectedServerConnexion=serverConnexion.value(selectedServer);
- if(selectedServerConnexion->host.isEmpty())
- {
- lastServerConnect[selectedServerConnexion->host]=QDateTime::currentDateTime();
- lastServerIsKick[selectedServerConnexion->host]=false;
- }
- if(customServerConnexion.contains(selectedServer))
- {
- if(selectedServerConnexion->host.isEmpty())
- settings.beginGroup(QString(selectedServerConnexion->ws.toUtf8().toHex()));
- else
- settings.beginGroup(QStringLiteral("%1-%2").arg(selectedServerConnexion->host).arg(selectedServerConnexion->port));
- }
- else
- settings.beginGroup(QStringLiteral("Xml-%1").arg(selectedServerConnexion->unique_code));*/
-
- QStringList loginList=settings.value("login").toStringList();
- if(serverLoginList.contains(ui->lineEditLogin->text()))
- loginList.removeOne(ui->lineEditLogin->text());
- if(ui->checkBoxRememberPassword->isChecked())
- {
- serverLoginList[ui->lineEditLogin->text()]=ui->lineEditPass->text();
- settings.setValue(ui->lineEditLogin->text(),ui->lineEditPass->text());
- }
- else
- {
- serverLoginList[ui->lineEditLogin->text()]=QString();
- settings.remove(ui->lineEditLogin->text());
- }
- loginList.insert(0,ui->lineEditLogin->text());
- settings.setValue("login",loginList);
- if(completer!=NULL)
- {
- delete completer;
- completer=NULL;
- }
-
- settings.endGroup();
- settings.sync();
- if(socket!=NULL)
- {
- socket->disconnectFromHost();
- socket->abort();
- delete socket;
- socket=NULL;
- #ifndef NOTCPSOCKET
- realSslSocket=nullptr;
- #endif
- #ifndef NOWEBSOCKET
- realWebSocket=nullptr;
- #endif
- }
- #if ! defined(NOTCPSOCKET) && ! defined(NOWEBSOCKET)
- /*if(!selectedServerConnexion->host.isEmpty())
- {
- realSslSocket=new QSslSocket();
- socket=new CatchChallenger::ConnectedSocket(realSslSocket);
- }
- else if(!selectedServerConnexion->ws.isEmpty())
- {
- realWebSocket=new QWebSocket();
- socket=new CatchChallenger::ConnectedSocket(realWebSocket);
- }
- else {
- std::cerr << "host and ws is empty" << std::endl;
- abort();
- }*/
- #else
- #ifndef NOTCPSOCKET
- if(!selectedServerConnexion->host.isEmpty())
- {
- realSslSocket=new QSslSocket();
- socket=new CatchChallenger::ConnectedSocket(realSslSocket);
- }
- else {
- std::cerr << "host is empty" << std::endl;
- abort();
- }
- #endif
- #ifndef NOWEBSOCKET
- if(!selectedServerConnexion->ws.isEmpty())
- {
- realWebSocket=new QWebSocket();
- socket=new CatchChallenger::ConnectedSocket(realWebSocket);
- }
- else {
- std::cerr << "ws is empty" << std::endl;
- abort();
- }
- #endif
- #endif
- CatchChallenger::Api_client_real *client=new CatchChallenger::Api_client_real(socket);
- this->client=client;
-
- if(!connect(client, &CatchChallenger::Api_client_real::Qtprotocol_is_good, this,&MainWindow::protocol_is_good,Qt::QueuedConnection))
- abort();
- if(!connect(client, &CatchChallenger::Api_client_real::Qtdisconnected, this,&MainWindow::disconnected))
- abort();
- //connect(client, &CatchChallenger::Api_protocol::Qtmessage, this,&MainWindow::message,Qt::QueuedConnection);
- if(!connect(client, &CatchChallenger::Api_client_real::Qtlogged, this,&MainWindow::logged,Qt::QueuedConnection))
- abort();
-
- if(!selectedServerConnexion->proxyHost.isEmpty())
- {
- QNetworkProxy proxy;
- #ifndef NOTCPSOCKET
- if(realSslSocket!=nullptr)
- proxy=realSslSocket->proxy();
- #endif
- #ifndef NOWEBSOCKET
- if(realWebSocket!=nullptr)
- proxy=realWebSocket->proxy();
- #endif
- proxy.setType(QNetworkProxy::Socks5Proxy);
- proxy.setHostName(selectedServerConnexion->proxyHost);
- proxy.setPort(selectedServerConnexion->proxyPort);
- #ifndef NOTCPSOCKET
- if(realSslSocket!=nullptr)
- realSslSocket->setProxy(proxy);
- #endif
- #ifndef NOWEBSOCKET
- if(realWebSocket!=nullptr)
- realWebSocket->setProxy(proxy);
- #endif
- }
- ui->stackedWidget->setCurrentWidget(baseWindow);
- baseWindow->setMultiPlayer(true,static_cast(client));
- baseWindow->stateChanged(QAbstractSocket::ConnectingState);
- #ifndef NOTCPSOCKET
- if(realSslSocket!=nullptr)
- {
- if(!connect(realSslSocket,static_cast &errors)>(&QSslSocket::sslErrors), this,&MainWindow::sslErrors,Qt::QueuedConnection))
- abort();
- if(!connect(realSslSocket,&QSslSocket::stateChanged, this,&MainWindow::stateChanged,Qt::DirectConnection))
- abort();
- if(!connect(realSslSocket,static_cast(&QSslSocket::error), this,&MainWindow::error,Qt::QueuedConnection))
- abort();
-
- lastServer=selectedServerConnexion->host+":"+QString::number(selectedServerConnexion->port);
- socket->connectToHost(selectedServerConnexion->host,selectedServerConnexion->port);
- }
- #endif
- #ifndef NOWEBSOCKET
- if(realWebSocket!=nullptr)
- {
- if(!connect(realWebSocket,&QWebSocket::stateChanged, this,&MainWindow::stateChanged,Qt::DirectConnection))
- abort();
- if(!connect(realWebSocket,static_cast(&QWebSocket::error), this,&MainWindow::error,Qt::QueuedConnection))
- abort();
-
- lastServer=selectedServerConnexion->ws;
- QUrl url{QString(selectedServerConnexion->ws)};
- QNetworkRequest request{url};
- request.setRawHeader("Sec-WebSocket-Protocol", "binary");
- realWebSocket->open(request);
- }
- #endif
- selectedServerConnexion->connexionCounter++;
- selectedServerConnexion->lastConnexion=static_cast(QDateTime::currentMSecsSinceEpoch()/1000);
- saveConnexionInfoList();
- connectTheExternalSocket();
- displayServerList();//need be after connectTheExternalSocket() because it reset selectedServer
-}
-
-void MainWindow::connectTheExternalSocket()
-{
- if(selectedServer==NULL)
- {
- qDebug() << "selectedServer==NULL, fix it!";
- abort();
- }
- if(!serverConnexion.contains(selectedServer))
- {
- qDebug() << "!serverConnexion.contains(selectedServer)";
- abort();
- }
- //continue the normal procedure
- if(!serverConnexion.value(selectedServer)->proxyHost.isEmpty())
- {
- QNetworkProxy proxy;
- #ifndef NOTCPSOCKET
- if(realSslSocket!=nullptr)
- proxy=realSslSocket->proxy();
- #endif
- #ifndef NOWEBSOCKET
- if(realWebSocket!=nullptr)
- proxy=realWebSocket->proxy();
- #endif
- proxy.setType(QNetworkProxy::Socks5Proxy);
- proxy.setHostName(serverConnexion.value(selectedServer)->proxyHost);
- proxy.setPort(serverConnexion.value(selectedServer)->proxyPort);
- static_cast(client)->setProxy(proxy);
- }
-
- baseWindow->connectAllSignals();
- baseWindow->setMultiPlayer(true,static_cast(client));
- QDir datapack(serverToDatapachPath(selectedServer));
- if(!datapack.exists())
- if(!datapack.mkpath(datapack.absolutePath()))
- {
- disconnected(tr("Not able to create the folder %1").arg(datapack.absolutePath()).toStdString());
- return;
- }
- client->setDatapackPath(datapack.absolutePath().toStdString());
- baseWindow->stateChanged(QAbstractSocket::ConnectedState);
-}
-
-QString MainWindow::serverToDatapachPath(ListEntryEnvolued * selectedServer) const
-{
- QDir datapack;
- if(customServerConnexion.contains(selectedServer))
- {
- if(!serverConnexion.value(selectedServer)->name.isEmpty())
- datapack=QDir(QStringLiteral("%1/datapack/%2/").arg(QStandardPaths::writableLocation(QStandardPaths::DataLocation)).arg(serverConnexion.value(selectedServer)->name));
- else
- datapack=QDir(QStringLiteral("%1/datapack/%2-%3/").arg(QStandardPaths::writableLocation(QStandardPaths::DataLocation)).arg(serverConnexion.value(selectedServer)->host).arg(serverConnexion.value(selectedServer)->port));
- }
- else
- datapack=QDir(QStringLiteral("%1/datapack/Xml-%2").arg(QStandardPaths::writableLocation(QStandardPaths::DataLocation)).arg(serverConnexion.value(selectedServer)->unique_code));
- return datapack.absolutePath();
-}
-
-void MainWindow::stateChanged(QAbstractSocket::SocketState socketState)
-{
- std::cout << "MainWindow::stateChanged(" << std::to_string((int)socketState) << ")" << std::endl;
- if(socketState==QAbstractSocket::ConnectedState)
- {
- //If comment: Internal problem: Api_protocol::sendProtocol() !haveFirstHeader
- #if !defined(NOTCPSOCKET) && !defined(NOWEBSOCKET)
- if(realSslSocket==NULL && realWebSocket==NULL)
- client->sendProtocol();
- /*else
- qDebug() << "Tcp/Web socket found, skip sendProtocol(), previouslusy send by void Api_protocol::connectTheExternalSocketInternal()";*/
- #elif !defined(NOTCPSOCKET)
- if(realSslSocket==NULL)
- client->sendProtocol();
- /*else
- qDebug() << "Tcp socket found, skip sendProtocol(), previouslusy send by void Api_protocol::connectTheExternalSocketInternal()";*/
- #elif !defined(NOWEBSOCKET)
- if(realWebSocket==NULL)
- client->sendProtocol();
- /*else
- qDebug() << "Web socket found, skip sendProtocol(), previouslusy send by void Api_protocol::connectTheExternalSocketInternal()";*/
- #endif
- }
- if(socketState==QAbstractSocket::UnconnectedState)
- {
- if(client!=NULL)
- {
- std::cout << "MainWindow::stateChanged(" << std::to_string((int)socketState) << ") client!=NULL" << std::endl;
- if(client->stage()==CatchChallenger::Api_client_real::StageConnexion::Stage2 || client->stage()==CatchChallenger::Api_client_real::StageConnexion::Stage3)
- {
- std::cout << "MainWindow::stateChanged(" << std::to_string((int)socketState) << ") call socketDisconnectedForReconnect" << std::endl;
- const std::string &lastServer=client->socketDisconnectedForReconnect();
- if(!lastServer.empty())
- this->lastServer=QString::fromStdString(lastServer);
- return;
- }
- }
- std::cout << "MainWindow::stateChanged(" << std::to_string((int)socketState) << ") mostly quit" << std::endl;
- if(!isVisible()
- #ifndef NOSINGLEPLAYER
- && internalServer==NULL
- #endif
- )
- {
- QCoreApplication::quit();
- return;
- }
- if(client!=NULL)
- static_cast(this->client)->closeDownload();
- if(client!=NULL && client->protocolWrong())
- QMessageBox::about(this,tr("Quit"),tr("The server have closed the connexion"));
- #ifndef NOSINGLEPLAYER
- if(internalServer!=NULL)
- internalServer->stop();
- #endif
- /* to fix bug: firstly try connect but connexion refused on localhost, secondly try local game */
- #ifndef NOTCPSOCKET
- if(realSslSocket!=NULL)
- {
- realSslSocket->deleteLater();
- realSslSocket=NULL;
- }
- #endif
- #ifndef NOWEBSOCKET
- if(realWebSocket!=NULL)
- {
- realWebSocket->deleteLater();
- realWebSocket=NULL;
- }
- #endif
- if(socket!=NULL)
- {
- socket->deleteLater();
- socket=NULL;
- }
- /*socket will do that's if(realSocket!=NULL)
- {
- delete realSocket;
- realSocket=NULL;
- }*/
- resetAll();
- /*if(serverMode==ServerMode_Remote)
- QMessageBox::about(this,tr("Quit"),tr("The server have closed the connexion"));*/
- }
- if(baseWindow!=NULL)
- baseWindow->stateChanged(socketState);
-}
-
-void MainWindow::error(QAbstractSocket::SocketError socketError)
-{
- if(client!=NULL)
- if(client->stage()==CatchChallenger::Api_client_real::StageConnexion::Stage2)
- return;
- QString additionalText;
- if(!lastServer.isEmpty())
- additionalText=tr(" on %1").arg(lastServer);
- resetAll();
- switch(socketError)
- {
- case QAbstractSocket::RemoteHostClosedError:
- #ifndef NOTCPSOCKET
- if(realSslSocket!=NULL)
- return;
- #endif
- #ifndef NOWEBSOCKET
- if(realWebSocket!=NULL)
- return;
- #endif
- if(haveShowDisconnectionReason)
- {
- haveShowDisconnectionReason=false;
- return;
- }
- QMessageBox::information(this,tr("Connection closed"),tr("Connection closed by the server")+additionalText);
- break;
- case QAbstractSocket::ConnectionRefusedError:
- QMessageBox::information(this,tr("Connection closed"),tr("Connection refused by the server")+additionalText);
- break;
- case QAbstractSocket::SocketTimeoutError:
- QMessageBox::information(this,tr("Connection closed"),tr("Socket time out, server too long")+additionalText);
- break;
- case QAbstractSocket::HostNotFoundError:
- QMessageBox::information(this,tr("Connection closed"),tr("The host address was not found")+additionalText);
- break;
- case QAbstractSocket::SocketAccessError:
- QMessageBox::information(this,tr("Connection closed"),tr("The socket operation failed because the application lacked the required privileges")+additionalText);
- break;
- case QAbstractSocket::SocketResourceError:
- QMessageBox::information(this,tr("Connection closed"),tr("The local system ran out of resources")+additionalText);
- break;
- case QAbstractSocket::NetworkError:
- QMessageBox::information(this,tr("Connection closed"),tr("An error occurred with the network (Connection refused on game server?)")+additionalText);
- break;
- case QAbstractSocket::UnsupportedSocketOperationError:
- QMessageBox::information(this,tr("Connection closed"),tr("The requested socket operation is not supported by the local operating system (e.g., lack of IPv6 support)")+additionalText);
- break;
- case QAbstractSocket::SslHandshakeFailedError:
- QMessageBox::information(this,tr("Connection closed"),tr("The SSL/TLS handshake failed, so the connection was closed")+additionalText);
- break;
- default:
- QMessageBox::information(this,tr("Connection error"),tr("Connection error: %1").arg(socketError)+additionalText);
- }
-}
-
-void MainWindow::newError(std::string error,std::string detailedError)
-{
- std::cout << "MainWindow::newError(): " << error << ": " << detailedError << std::endl;
- if(client!=NULL)
- client->tryDisconnect();
- QMessageBox::critical(this,tr("Error"),QString::fromStdString(error));
-}
-
-void MainWindow::haveNewError()
-{
- //QMessageBox::critical(this,tr("Error"),client->errorString());
-}
-
-void MainWindow::message(std::string message)
-{
- std::cout << message << std::endl;
-}
-
-void MainWindow::protocol_is_good()
-{
- if(serverMode==ServerMode_Internal)
- client->tryLogin("admin",pass.toStdString());
- else
- client->tryLogin(ui->lineEditLogin->text().toStdString(),ui->lineEditPass->text().toStdString());
-}
-
-void MainWindow::needQuit()
-{
- client->tryDisconnect();
-}
-
-void MainWindow::ListEntryEnvoluedClicked()
-{
- ListEntryEnvolued * selectedSavegame=qobject_cast(QObject::sender());
- if(selectedSavegame==NULL)
- return;
- this->selectedDatapack=selectedSavegame;
- ListEntryEnvoluedUpdate();
-}
-
-void MainWindow::ListEntryEnvoluedUpdate()
-{
- unsigned int index=0;
- while(indexsetStyleSheet(QStringLiteral("QLabel{border:1px solid #6b6;background-color:rgb(100,180,100,120);border-radius:10px;}QLabel::hover{border:1px solid #494;background-color:rgb(70,150,70,120);border-radius:10px;}"));
- else
- datapack.at(index)->setStyleSheet(QStringLiteral("QLabel::hover{border:1px solid #bbb;background-color:rgb(180,180,180,100);border-radius:10px;}"));
- index++;
- }
- ui->deleteDatapack->setEnabled(selectedDatapack!=NULL &&
- (datapackPathList[selectedDatapack]!=QFileInfo(QCoreApplication::applicationDirPath()+QStringLiteral("/datapack/internal")).absoluteFilePath()
- ||
- datapackPathList[selectedDatapack]!=QFileInfo(QCoreApplication::applicationDirPath()+QStringLiteral("/datapack/Internal")).absoluteFilePath())
- );
-}
-
-void MainWindow::ListEntryEnvoluedDoubleClicked()
-{
- on_deleteDatapack_clicked();
-}
-
-std::pair MainWindow::getDatapackInformations(const std::string &filePath)
-{
- std::pair returnVar;
- returnVar.first=tr("Unknown").toStdString();
- returnVar.second=tr("Unknown").toStdString();
- //open and quick check the file
- tinyxml2::XMLDocument domDocument;
- const auto loadOkay = domDocument.LoadFile(filePath.c_str());
- if(loadOkay!=0)
- {
- std::cerr << filePath+", "+domDocument.ErrorName() << std::endl;
- return returnVar;
- }
- const tinyxml2::XMLElement *root = domDocument.RootElement();
- if(root==NULL)
- {
- qDebug() << QStringLiteral("Unable to open the file: %1, \"informations\" root balise not found for the xml file")
- .arg(QString::fromStdString(filePath));
- return returnVar;
- }
- if(root->Name()==NULL)
- {
- qDebug() << QStringLiteral("Unable to open the file: %1, \"informations\" root balise not found 2 for the xml file")
- .arg(QString::fromStdString(filePath));
- return returnVar;
- }
- if(strcmp(root->Name(),"informations")!=0)
- {
- qDebug() << QStringLiteral("Unable to open the file: %1, \"informations\" root balise not found for the xml file")
- .arg(QString::fromStdString(filePath));
- return returnVar;
- }
-
- QStringList authors;
- //load the content
- const tinyxml2::XMLElement *item = root->FirstChildElement("author");
- while(item!=NULL)
- {
- if(item->Attribute("pseudo")!=NULL && item->Attribute("name")!=NULL)
- authors << QStringLiteral("%1 (%2)").arg(item->Attribute("pseudo")).arg(item->Attribute("name"));
- else if(item->Attribute("name")!=NULL)
- authors << item->Attribute("name");
- else if(item->Attribute("pseudo")!=NULL)
- authors << item->Attribute("pseudo");
- item = item->NextSiblingElement("author");
- }
- if(authors.isEmpty())
- returnVar.first=tr("Unknown").toStdString();
- else
- returnVar.first=authors.join(QStringLiteral(", ")).toStdString();
-
- returnVar.second=tr("Unknown").toStdString();
- item = root->FirstChildElement("name");
- bool found=false;
- const std::string &language=LanguagesSelect::languagesSelect->getCurrentLanguages();
- if(!language.empty() && language!="en")
- while(item!=NULL)
- {
- if(item->Attribute("lang")!=NULL && item->Attribute("lang")==language && item->GetText()!=NULL)
- {
- returnVar.second=item->GetText();
- found=true;
- break;
- }
- item = item->NextSiblingElement("name");
- }
- if(!found)
- {
- item = root->FirstChildElement("name");
- while(item!=NULL)
- {
- if(item->Attribute("lang")==NULL || strcmp(item->Attribute("lang"),"en")==0)
- if(item->GetText()!=NULL)
- {
- returnVar.second=item->GetText();
- break;
- }
- item = item->NextSiblingElement("name");
- }
- }
- return returnVar;
-}
-
-void MainWindow::on_manageDatapack_clicked()
-{
- QString lastSelectedPath;
- if(selectedDatapack!=NULL)
- lastSelectedPath=datapackPathList[selectedDatapack];
- selectedDatapack=NULL;
- int index=0;
- while(datapack.size()>0)
- {
- delete datapack.at(0);
- datapack.erase(datapack.begin());
- index++;
- }
- datapackPathList.clear();
- QFileInfoList entryList=QDir(QCoreApplication::applicationDirPath()+QStringLiteral("/datapack/")).entryInfoList(QDir::AllEntries|QDir::NoDotAndDotDot|QDir::Hidden|QDir::System,QDir::DirsFirst);//possible wait time here
- index=0;
- if(entryList.isEmpty())
- ui->datapackEmpty->setText(QStringLiteral("%1
").arg(tr("Empty")));
- while(index tempVar=getDatapackInformations(fileInfo.absoluteFilePath().toStdString()+
- "/informations.xml");
- QString author=QString::fromStdString(tempVar.first);
- QString name=QString::fromStdString(tempVar.second);
- ListEntryEnvolued *newEntry=new ListEntryEnvolued();
- if(!connect(newEntry,&ListEntryEnvolued::clicked,this,&MainWindow::ListEntryEnvoluedClicked,Qt::QueuedConnection))
- abort();
- if(!connect(newEntry,&ListEntryEnvolued::doubleClicked,this,&MainWindow::ListEntryEnvoluedDoubleClicked,Qt::QueuedConnection))
- abort();
- QString from;
- if(fileInfo.fileName()==QStringLiteral("Internal") || fileInfo.fileName()==QStringLiteral("internal"))
- from=tr("Internal datapack");
- else
- {
- from=tr("Get from %1").arg(fileInfo.fileName());
- from=from.replace(QRegularExpression(QStringLiteral("-([0-9]+)$")),QStringLiteral(", ")+tr("port %1").arg(QStringLiteral("\\1")));
- }
- newEntry->setStyleSheet(QStringLiteral("QLabel::hover{border:1px solid #bbb;background-color:rgb(180,180,180,100);border-radius:10px;}"));
- newEntry->setText(QStringLiteral("%1
%2
%3")
- .arg(name)
- .arg(tr("Author: %1").arg(author))
- .arg(from)
- );
- ui->scrollAreaWidgetContents->layout()->addWidget(newEntry);
-
- datapack.push_back(newEntry);
- datapackPathList[newEntry]=fileInfo.absoluteFilePath();
- index++;
- }
- ui->datapackWidget->setVisible(index==0);
- if(index>0)
- {
- ui->scrollAreaWidgetContents->layout()->removeItem(spacer);
- delete spacer;
- spacer=new QSpacerItem(0,0,QSizePolicy::Expanding,QSizePolicy::Expanding);
- ui->scrollAreaWidgetContents->layout()->addItem(spacer);
- }
- ListEntryEnvoluedUpdate();
- ui->stackedWidget->setCurrentWidget(ui->datapack);
-}
-
-void MainWindow::on_backDatapack_clicked()
-{
- ui->stackedWidget->setCurrentWidget(ui->poolServersList);
-}
-
-void MainWindow::on_deleteDatapack_clicked()
-{
- QMessageBox::StandardButton button=QMessageBox::question(this,tr("Are you sure?"),tr("Are you sure delete the datapack? This operation is not reversible."),QMessageBox::Yes|QMessageBox::No,QMessageBox::No);
- if(button!=QMessageBox::Yes)
- return;
- if(!CatchChallenger::FacilityLibGeneral::rmpath(datapackPathList[selectedDatapack].toStdString()))
- QMessageBox::warning(this,tr("Error"),tr("Remove the datapack path is not completed. Try after restarting the application"));
- on_manageDatapack_clicked();
-}
-
-void MainWindow::metaDataChanged()
-{
- if(!QFileInfo(QStandardPaths::writableLocation(QStandardPaths::DataLocation)+QStringLiteral("/server_list.xml")).isFile())
- return;
- QVariant val=reply->header(QNetworkRequest::LastModifiedHeader);
- if(!val.isValid())
- return;
- if(val.toDateTime()==QFileInfo(QStandardPaths::writableLocation(QStandardPaths::DataLocation)+QStringLiteral("/server_list.xml")).lastModified())
- {
- reply->abort();
- reply->deleteLater();
- ui->warning->setVisible(false);
- ui->server_refresh->setEnabled(true);
- reply=NULL;
- return;
- }
-}
-
-void MainWindow::on_multiplayer_clicked()
-{
- ui->stackedWidget->setCurrentWidget(ui->poolServersList);
-}
-
-void MainWindow::on_server_back_clicked()
-{
- ui->stackedWidget->setCurrentWidget(ui->mode);
-}
-
-#ifndef NOSINGLEPLAYER
-void MainWindow::gameSolo_play(const std::string &savegamesPath)
-{
- resetAll();
- if(socket!=NULL)
- {
- socket->disconnectFromHost();
- socket->abort();
- delete socket;
- socket=NULL;
- realSslSocket=NULL;
- }
- socket=new CatchChallenger::ConnectedSocket(new CatchChallenger::QFakeSocket());
- CatchChallenger::Api_client_virtual *client=new CatchChallenger::Api_client_virtual(socket);//QCoreApplication::applicationDirPath()+QStringLiteral("/datapack/internal/")
- this->client=client;
-
- if(!connect(client, &CatchChallenger::Api_protocol_Qt::Qtprotocol_is_good, this,&MainWindow::protocol_is_good))
- abort();
- if(!connect(client, &CatchChallenger::Api_protocol_Qt::Qtdisconnected, this,&MainWindow::disconnected))
- abort();
- if(!connect(client, &CatchChallenger::Api_protocol_Qt::Qtmessage, this,&MainWindow::message))
- abort();
- if(!connect(socket, &CatchChallenger::ConnectedSocket::stateChanged, this,&MainWindow::stateChanged))
- abort();
- baseWindow->setMultiPlayer(false,static_cast(this->client));
- baseWindow->connectAllSignals();//need always be after setMultiPlayer()
- client->setDatapackPath(QCoreApplication::applicationDirPath().toStdString()+"/datapack/internal/");
- baseWindow->mapController->setDatapackPath(client->datapackPathBase(),client->mainDatapackCode());
- serverMode=ServerMode_Internal;
- ui->stackedWidget->setCurrentWidget(baseWindow);
- timeLaunched=QDateTime::currentDateTimeUtc().toTime_t();
- QSettings metaData(QString::fromStdString(savegamesPath)+QStringLiteral("metadata.conf"),QSettings::IniFormat);
- if(!metaData.contains(QStringLiteral("pass")))
- {
- QMessageBox::critical(NULL,tr("Error"),tr("Unable to load internal value"));
- return;
- }
- launchedGamePath=QString::fromStdString(savegamesPath);
- haveLaunchedGame=true;
- pass=metaData.value(QStringLiteral("pass")).toString();
- if(internalServer!=NULL)
- delete internalServer;
- internalServer=new CatchChallenger::InternalServer(metaData);
- if(!sendSettings(internalServer,QString::fromStdString(savegamesPath)))
- return;
- if(!connect(internalServer,&CatchChallenger::InternalServer::is_started,this,&MainWindow::is_started,Qt::QueuedConnection))
- abort();
- if(!connect(internalServer,&CatchChallenger::InternalServer::error,this,&MainWindow::serverErrorStd,Qt::QueuedConnection))
- abort();
- internalServer->start();
-
- baseWindow->serverIsLoading();
-}
-
-void MainWindow::gameSolo_back()
-{
- ui->stackedWidget->setCurrentWidget(ui->mode);
-}
-
-void MainWindow::on_solo_clicked()
-{
- int index=ui->stackedWidget->indexOf(solowindow);
- if(index>=0)
- ui->stackedWidget->setCurrentWidget(solowindow);
- else
- QMessageBox::critical(this,"Bug prevent","Sorry but some Qt version is buggy, it's why this section is closed.");
-}
-
-bool MainWindow::sendSettings(CatchChallenger::InternalServer * internalServer,const QString &savegamesPath)
-{
- CatchChallenger::GameServerSettings formatedServerSettings=internalServer->getSettings();
-
- CommonSettingsServer::commonSettingsServer.waitBeforeConnectAfterKick=0;
- CommonSettingsCommon::commonSettingsCommon.max_character=1;
- CommonSettingsCommon::commonSettingsCommon.min_character=1;
-
- formatedServerSettings.automatic_account_creation=true;
- formatedServerSettings.max_players=1;
- formatedServerSettings.sendPlayerNumber = false;
- formatedServerSettings.compressionType=CatchChallenger::CompressionType_None;
- formatedServerSettings.everyBodyIsRoot = true;
- formatedServerSettings.teleportIfMapNotFoundOrOutOfMap = true;
-
- formatedServerSettings.database_login.tryOpenType=CatchChallenger::DatabaseBase::DatabaseType::SQLite;
- formatedServerSettings.database_login.file=(savegamesPath+QStringLiteral("catchchallenger.db.sqlite")).toStdString();
- formatedServerSettings.database_base.tryOpenType=CatchChallenger::DatabaseBase::DatabaseType::SQLite;
- formatedServerSettings.database_base.file=(savegamesPath+QStringLiteral("catchchallenger.db.sqlite")).toStdString();
- formatedServerSettings.database_common.tryOpenType=CatchChallenger::DatabaseBase::DatabaseType::SQLite;
- formatedServerSettings.database_common.file=(savegamesPath+QStringLiteral("catchchallenger.db.sqlite")).toStdString();
- formatedServerSettings.database_server.tryOpenType=CatchChallenger::DatabaseBase::DatabaseType::SQLite;
- formatedServerSettings.database_server.file=(savegamesPath+QStringLiteral("catchchallenger.db.sqlite")).toStdString();
- formatedServerSettings.mapVisibility.mapVisibilityAlgorithm = CatchChallenger::MapVisibilityAlgorithmSelection_None;
- formatedServerSettings.datapack_basePath=client->datapackPathBase();
-
- {
- CatchChallenger::GameServerSettings::ProgrammedEvent &event=formatedServerSettings.programmedEventList["day"]["day"];
- event.cycle=60;
- event.offset=0;
- event.value="day";
- }
- {
- CatchChallenger::GameServerSettings::ProgrammedEvent &event=formatedServerSettings.programmedEventList["day"]["night"];
- event.cycle=60;
- event.offset=30;
- event.value="night";
- }
- settings.beginGroup("content");
- if(settings.contains("mainDatapackCode"))
- CommonSettingsServer::commonSettingsServer.mainDatapackCode=settings.value("mainDatapackCode","[main]").toString().toStdString();
- else
- {
- const QFileInfoList &list=QDir(QString::fromStdString(client->datapackPathBase())+"/map/main/")
- .entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot,QDir::Name);
- if(list.isEmpty())
- {
- QMessageBox::critical(this,tr("Error"),tr("No main code detected into the current datapack"));
- return false;
- }
- settings.setValue("mainDatapackCode",list.at(0).fileName());
- CommonSettingsServer::commonSettingsServer.mainDatapackCode=list.at(0).fileName().toStdString();
- }
- QDir mainDir(QString::fromStdString(client->datapackPathBase())+"map/main/"+
- QString::fromStdString(CommonSettingsServer::commonSettingsServer.mainDatapackCode)+"/");
- if(!mainDir.exists())
- {
- const QFileInfoList &list=QDir(QString::fromStdString(client->datapackPathBase())+"/map/main/")
- .entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot,QDir::Name);
- if(list.isEmpty())
- {
- QMessageBox::critical(this,tr("Error"),tr("No main code detected into the current datapack"));
- return false;
- }
- settings.setValue("mainDatapackCode",list.at(0).fileName());
- CommonSettingsServer::commonSettingsServer.mainDatapackCode=list.at(0).fileName().toStdString();
- }
-
- if(settings.contains("subDatapackCode"))
- CommonSettingsServer::commonSettingsServer.subDatapackCode=settings.value("subDatapackCode","").toString().toStdString();
- else
- {
- const QFileInfoList &list=QDir(QString::fromStdString(client->datapackPathBase())+"/map/main/"+
- QString::fromStdString(CommonSettingsServer::commonSettingsServer.mainDatapackCode)+"/sub/")
- .entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot,QDir::Name);
- if(!list.isEmpty())
- {
- settings.setValue("subDatapackCode",list.at(0).fileName());
- CommonSettingsServer::commonSettingsServer.subDatapackCode=list.at(0).fileName().toStdString();
- }
- else
- CommonSettingsServer::commonSettingsServer.subDatapackCode.clear();
- }
- if(!CommonSettingsServer::commonSettingsServer.subDatapackCode.empty())
- {
- QDir subDir(QString::fromStdString(client->datapackPathBase())+"/map/main/"+
- QString::fromStdString(CommonSettingsServer::commonSettingsServer.mainDatapackCode)+"/sub/"+
- QString::fromStdString(CommonSettingsServer::commonSettingsServer.subDatapackCode)+"/");
- if(!subDir.exists())
- {
- const QFileInfoList &list=QDir(QString::fromStdString(client->datapackPathBase())+"/map/main/"+
- QString::fromStdString(CommonSettingsServer::commonSettingsServer.mainDatapackCode)+"/sub/")
- .entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot,QDir::Name);
- if(!list.isEmpty())
- {
- settings.setValue("subDatapackCode",list.at(0).fileName());
- CommonSettingsServer::commonSettingsServer.subDatapackCode=list.at(0).fileName().toStdString();
- }
- else
- CommonSettingsServer::commonSettingsServer.subDatapackCode.clear();
- }
- }
- settings.endGroup();
-
- internalServer->setSettings(formatedServerSettings);
- return true;
-}
-
-void MainWindow::saveTime()
-{
- if(serverMode!=ServerMode_Internal)
- return;
- if(internalServer==NULL)
- return;
- //save the time
- if(haveLaunchedGame)
- {
- bool settingOk=false;
- QSettings metaData(launchedGamePath+QStringLiteral("metadata.conf"),QSettings::IniFormat);
- if(metaData.isWritable())
- {
- if(metaData.status()==QSettings::NoError)
- {
- QString locaction=QString::fromStdString(baseWindow->lastLocation());
- const QString &mapPath=QString::fromStdString(internalServer->getSettings().datapack_basePath)+DATAPACK_BASE_PATH_MAPMAIN+QString::fromStdString(CommonSettingsServer::commonSettingsServer.mainDatapackCode)+"/";//internalServer->getSettings().mainDatapackCode
- if(locaction.startsWith(mapPath))
- locaction.remove(0,mapPath.size());
- if(!locaction.isEmpty())
- metaData.setValue(QStringLiteral("location"),locaction);
- uint64_t current_date_time=QDateTime::currentDateTimeUtc().toTime_t();
- if(current_date_time>timeLaunched)
- metaData.setValue("time_played",metaData.value("time_played").toUInt()+(uint32_t)(current_date_time-timeLaunched));
- settingOk=true;
- }
- else
- qDebug() << "Settings error: " << metaData.status();
- }
- solowindow->updateSavegameList();
- if(!settingOk)
- {
- QMessageBox::critical(NULL,tr("Error"),tr("Unable to save internal value at game stopping"));
- return;
- }
- haveLaunchedGame=false;
- }
-}
-#endif
-
-void MainWindow::serverError(const QString &error)
-{
- QMessageBox::critical(NULL,tr("Error"),tr("The engine is closed due to: %1").arg(error));
- resetAll();
-}
-
-void MainWindow::serverErrorStd(const std::string &error)
-{
- QMessageBox::critical(NULL,tr("Error"),tr("The engine is closed due to: %1").arg(QString::fromStdString(error)));
- resetAll();
-}
-
-void MainWindow::is_started(bool started)
-{
- if(!started)
- {
- #ifndef NOSINGLEPLAYER
- if(internalServer!=NULL)
- {
- delete internalServer;
- internalServer=NULL;
- }
- #endif
- if(!isVisible())
- QCoreApplication::quit();
- else
- resetAll();
- }
- else
- {
- baseWindow->serverIsReady();
- lastServer="localhost:9999";
- socket->connectToHost(QStringLiteral("localhost"),9999);
- }
-}
-
-void MainWindow::on_languages_clicked()
-{
- LanguagesSelect::languagesSelect->exec();
-}
-
-#ifndef __EMSCRIPTEN__
-void MainWindow::newUpdate(const std::string &version)
-{
- ui->update->setText(QString::fromStdString(InternetUpdater::getText(version)));
- ui->update->setVisible(true);
-}
-#endif
-
-void MainWindow::feedEntryList(const std::vector &entryList, std::string error=std::string())
-{
- if(entryList.empty())
- {
- if(error.empty())
- ui->news->setVisible(false);
- else
- {
- ui->news->setToolTip(QString::fromStdString(error));
- ui->news->setStyleSheet("#news{background-color: rgb(220, 220, 240);\nborder: 1px solid rgb(100, 150, 240);\nborder-radius:5px;\ncolor: rgb(0, 0, 0);\nbackground-image: url(:/CC/images/multi/warning.png);\nbackground-repeat: no-repeat;\nbackground-position: right;}");
- }
- return;
- }
- if(entryList.size()==1)
- ui->news->setText(tr("Latest news:")+" "+QStringLiteral("%2")
- .arg(QString::fromStdString(entryList.at(0).link))
- .arg(QString::fromStdString(entryList.at(0).title)));
- else
- {
- QStringList entryHtmlList;
- unsigned int index=0;
- while(index%2")
- .arg(QString::fromStdString(entryList.at(index).link))
- .arg(QString::fromStdString(entryList.at(index).title));
- index++;
- }
- ui->news->setText(tr("Latest news:")+QStringLiteral("
")+entryHtmlList.join("
"));
- }
- settings.setValue("news",ui->news->text());
- ui->news->setStyleSheet("#news{background-color:rgb(220,220,240);border:1px solid rgb(100,150,240);border-radius:5px;color:rgb(0,0,0);}");
- ui->news->setVisible(true);
-}
-
-void MainWindow::on_lineEditLogin_textChanged(const QString &arg1)
-{
- if(serverLoginList.contains(arg1))
- ui->lineEditPass->setText(serverLoginList.value(arg1));
- else
- ui->lineEditPass->setText(QString());
-}
-
-void MainWindow::logged()
-{
- if(serverConnexion.contains(selectedServer))
- lastServerWaitBeforeConnectAfterKick[serverConnexion.value(selectedServer)->host]=CommonSettingsServer::commonSettingsServer.waitBeforeConnectAfterKick;
-}
-
-void MainWindow::gameIsLoaded()
-{
- #ifndef CATCHCHALLENGER_NOAUDIO
- if(player!=NULL)
- player->stop();
- #endif
- this->setWindowTitle(QStringLiteral("CatchChallenger Ultimate - %1").arg(QString::fromStdString(client->getPseudo())));
-}
-
-void MainWindow::updateTheOkButton()
-{
- if(selectedServer==NULL)
- {
- ui->pushButtonTryLogin->setEnabled(true);
- ui->pushButtonTryLogin->setText(tr("Ok"));
- return;
- }
- if(!serverConnexion.contains(selectedServer))
- {
- ui->pushButtonTryLogin->setEnabled(true);
- ui->pushButtonTryLogin->setText(tr("Ok"));
- return;
- }
- if(!lastServerWaitBeforeConnectAfterKick.contains(serverConnexion.value(selectedServer)->host))
- {
- ui->pushButtonTryLogin->setEnabled(true);
- ui->pushButtonTryLogin->setText(tr("Ok"));
- return;
- }
- if(!lastServerConnect.contains(serverConnexion.value(selectedServer)->host))
- {
- ui->pushButtonTryLogin->setEnabled(true);
- ui->pushButtonTryLogin->setText(tr("Ok"));
- return;
- }
- uint32_t timeToWait=5;
- if(lastServerIsKick.value(serverConnexion.value(selectedServer)->host))
- if(lastServerWaitBeforeConnectAfterKick.value(serverConnexion.value(selectedServer)->host)>timeToWait)
- timeToWait=lastServerWaitBeforeConnectAfterKick.value(serverConnexion.value(selectedServer)->host);
- uint32_t secondLastSinceConnexion=QDateTime::currentDateTime().toTime_t()-lastServerConnect.value(serverConnexion.value(selectedServer)->host).toTime_t();
- if(secondLastSinceConnexion>=timeToWait)
- {
- ui->pushButtonTryLogin->setEnabled(true);
- ui->pushButtonTryLogin->setText(tr("Ok"));
- return;
- }
- else
- {
- ui->pushButtonTryLogin->setEnabled(false);
- ui->pushButtonTryLogin->setText(tr("Ok (%1)").arg(timeToWait-secondLastSinceConnexion));
- return;
- }
-}
-
-void MainWindow::on_server_edit_clicked()
-{
- if(selectedServer==NULL)
- return;
- if(!customServerConnexion.contains(selectedServer))
- return;
- unsigned int index=0;
- while(indexname);
-
- if(connexionInfo->ws.isEmpty())
- {
- editServer.setType(0);
- editServer.setServer(connexionInfo->host);
- editServer.setPort(connexionInfo->port);
- }
- else
- {
- editServer.setType(1);
- editServer.setServer(connexionInfo->ws);
- editServer.setPort(connexionInfo->port);
- }
-
- editServer.setProxyServer(connexionInfo->proxyHost);
- editServer.setProxyPort(connexionInfo->proxyPort);
- editServer.exec();
- if(!editServer.isOk())
- return;
- if(editServer.type()==0)
- {
- if(!editServer.server().contains(QRegularExpression("^[a-zA-Z0-9\\.:\\-_]+$")))
- {
- QMessageBox::warning(this,tr("Error"),tr("The host seam don't be a valid hostname or ip"));
- return;
- }
- }
- else
- {
- if(!editServer.server().startsWith("ws://") && !editServer.server().startsWith("wss://"))
- {
- QMessageBox::warning(this,tr("Error"),tr("The web socket url seam wrong, not start with ws:// or wss://"));
- return;
- }
- }
- if(customServerName.contains(editServer.name()) && editServer.name()!=connexionInfo->name)
- {
- QMessageBox::warning(this,tr("Error"),tr("The name is already taken"));
- return;
- }
- if(editServer.name()!=connexionInfo->name)
- {
- customServerName.remove(connexionInfo->name);
- customServerName << editServer.name();
- }
-
- connexionInfo->name=editServer.name();
- if(editServer.type()==0)
- {
- #ifndef NOTCPSOCKET
- connexionInfo->host=editServer.server();
- #endif
- connexionInfo->port=editServer.port();
- connexionInfo->ws.clear();
- }
- else
- {
- #ifndef NOWEBSOCKET
- connexionInfo->ws=editServer.server();
- #endif
- connexionInfo->port=editServer.port();
- connexionInfo->host.clear();
- }
- connexionInfo->proxyHost=editServer.proxyServer();
- connexionInfo->proxyPort=editServer.proxyPort();
-
- saveConnexionInfoList();
- displayServerList();
- break;
- }
- index++;
- }
-}
-
-void MainWindow::on_showPassword_toggled(bool)
-{
- if(ui->showPassword->isChecked())
- ui->lineEditPass->setEchoMode(QLineEdit::Normal);
- else
- ui->lineEditPass->setEchoMode(QLineEdit::Password);
-}
-
-void MainWindow::on_UltimateKey_clicked()
-{
- askForUltimateCopy();
-}
-
-void MainWindow::on_login_cancel_clicked()
-{
- ui->stackedWidget->setCurrentWidget(ui->poolServersList);
-}
-
-void MainWindow::on_server_select_clicked()
-{
- if(!serverConnexion.contains(selectedServer))
- {
- QMessageBox::warning(this,tr("Internal error"),tr("Internal error: Can't select this server"));
- return;
- }
- ui->stackedWidget->setCurrentWidget(ui->login);
- updateTheOkButton();
- ConnexionInfo * connexionInfo=serverConnexion[selectedServer];
- if(connexionInfo->host.isEmpty())
- settings.beginGroup(QString(connexionInfo->ws.toUtf8().toHex()));
- else if(customServerConnexion.contains(selectedServer))
- settings.beginGroup(QStringLiteral("%1-%2").arg(connexionInfo->host).arg(connexionInfo->port));
- else
- settings.beginGroup(QStringLiteral("Xml-%1").arg(connexionInfo->unique_code));
- if(!serverConnexion.value(selectedServer)->register_page.isEmpty())
- {
- ui->label_login_register->setVisible(true);
- ui->label_login_register->setText(tr("Register").arg(serverConnexion.value(selectedServer)->register_page));
- }
- else
- ui->label_login_register->setVisible(false);
- if(!serverConnexion.value(selectedServer)->site_page.isEmpty())
- {
- ui->label_login_website->setVisible(true);
- ui->label_login_website->setText(tr("Web site").arg(serverConnexion.value(selectedServer)->site_page));
- }
- else
- ui->label_login_website->setVisible(false);
- serverLoginList.clear();
- if(settings.contains(QStringLiteral("login")))
- {
- const QStringList &loginList=settings.value("login").toStringList();
- int index=0;
- while(indexsetCaseSensitivity(Qt::CaseInsensitive);
- ui->lineEditLogin->setCompleter(completer);
-
- ui->lineEditLogin->setText(loginList.first());
- }
- else
- ui->lineEditLogin->setText(QString());
- }
- else
- ui->lineEditLogin->setText(QString());
- if(serverLoginList.contains(ui->lineEditLogin->text()))
- ui->lineEditPass->setText(serverLoginList.value(ui->lineEditLogin->text()));
- else
- ui->lineEditPass->setText(QString());
- settings.endGroup();
- ui->checkBoxRememberPassword->setChecked(!ui->lineEditPass->text().isEmpty());
-}
diff --git a/client/cpu/mainwindow.h b/client/cpu/mainwindow.h
deleted file mode 100644
index c1b9917b3..000000000
--- a/client/cpu/mainwindow.h
+++ /dev/null
@@ -1,160 +0,0 @@
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include
-#include
-#include
-#ifndef __EMSCRIPTEN__
-#include
-#else
-#include
-#endif
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "../qt/ClientVariableAudio.h"
-#ifndef CATCHCHALLENGER_NOAUDIO
-#include "../qt/QInfiniteBuffer.h"
-#endif
-
-#include "../../general/base/ChatParsing.h"
-#include "../../general/base/GeneralStructures.h"
-#include "../qt/ConnectedSocket.h"
-#include "../qt/FeedNews.h"
-#ifndef CATCHCHALLENGER_NOAUDIO
-#include "../qt/Audio.h"
-#endif
-#include "../qt/Api_client_real.h"
-#include "../qt/render/MapController.h"
-#include "../qt/interface/BaseWindow.h"
-#ifndef NOSINGLEPLAYER
-#include "../qt/solo/SoloWindow.h"
-#endif
-#include "../qt/LanguagesSelect.h"
-
-namespace Ui {
- class MainWindow;
-}
-
-class AddOrEditServer;
-
-class MainWindow : public QMainWindow
-{
- Q_OBJECT
-public:
- explicit MainWindow(QWidget *parent = 0);
- ~MainWindow();
- bool toQuit;
-protected:
- void changeEvent(QEvent *e);
-private slots:
- void on_lineEditLogin_returnPressed();
- void on_lineEditPass_returnPressed();
- void on_pushButtonTryLogin_clicked();
- void connectTheExternalSocket();
- QString serverToDatapachPath(ListEntryEnvolued *selectedServer) const;
- void stateChanged(QAbstractSocket::SocketState socketState);
- void error(QAbstractSocket::SocketError socketError);
- void haveNewError();
- void newError(std::string error, std::string detailedError);
- void message(std::string message);
- void disconnected(std::string reason);
- void protocol_is_good();
- void needQuit();
- #ifndef __EMSCRIPTEN__
- void sslErrors(const QList &errors);
- #endif
- void ListEntryEnvoluedClicked();
- void ListEntryEnvoluedDoubleClicked();
- void ListEntryEnvoluedUpdate();
- void serverListEntryEnvoluedClicked();
- void serverListEntryEnvoluedDoubleClicked();
- void serverListEntryEnvoluedUpdate();
- void on_manageDatapack_clicked();
- std::pair getDatapackInformations(const std::string &filePath);
- void on_backDatapack_clicked();
- void on_deleteDatapack_clicked();
- void on_login_cancel_clicked();
- void closeEvent(QCloseEvent *event);
- void downloadFile();
- void metaDataChanged();
- void httpFinished();
- void on_multiplayer_clicked();
- void on_server_back_clicked();
- #ifndef NOSINGLEPLAYER
- void gameSolo_play(const std::string &savegamesPath);
- void gameSolo_back();
- void on_solo_clicked();
- bool sendSettings(CatchChallenger::InternalServer * internalServer,const QString &savegamesPath);
- void saveTime();
- #endif
- void is_started(bool started);
- void serverError(const QString &error);
- void serverErrorStd(const std::string &error);
- void on_languages_clicked();
- #ifndef __EMSCRIPTEN__
- void newUpdate(const std::string &version);
- #endif
- void feedEntryList(const std::vector &entryList, std::string error);
- void on_lineEditLogin_textChanged(const QString &arg1);
- void logged();
- void gameIsLoaded();
- void updateTheOkButton();
- void on_server_edit_clicked();
- bool askForUltimateCopy();
- void on_showPassword_toggled(bool);
- void on_UltimateKey_clicked();
-private:
- enum ServerMode
- {
- ServerMode_Internal,
- ServerMode_Remote,
- ServerMode_None
- };
- ServerMode serverMode;
- QSpacerItem *spacer;
- QSpacerItem *spacerServer;
- Ui::MainWindow *ui;
- void resetAll();
- QSettings settings;
- bool haveShowDisconnectionReason;
- QStringList server_list;
- CatchChallenger::ConnectedSocket *socket;
- #ifndef NOTCPSOCKET
- QSslSocket *realSslSocket;
- #endif
- #ifndef NOWEBSOCKET
- QWebSocket *realWebSocket;
- #endif
- #ifndef NOSINGLEPLAYER
- SoloWindow *solowindow;
- #endif
- QString pass;
- uint64_t timeLaunched;
- QString launchedGamePath;
- bool haveLaunchedGame;
- #ifndef NOSINGLEPLAYER
- CatchChallenger::InternalServer * internalServer;
- #endif
- QSet customServerName;
- QHash serverLoginList;
- QHash lastServerConnect;
- QHash lastServerWaitBeforeConnectAfterKick;
- QHash lastServerIsKick;
- QTimer updateTheOkButtonTimer;
- CatchChallenger::BaseWindow *baseWindow;
- CatchChallenger::Api_protocol *client;
- QCompleter *completer;
- QString lastServer;
- #ifndef CATCHCHALLENGER_NOAUDIO
- QAudioOutput *player;
- QInfiniteBuffer buffer;
- QByteArray data;
- #endif
-};
-
-#endif // MAINWINDOW_H
diff --git a/client/cpu/specific.pri b/client/cpu/specific.pri
deleted file mode 100644
index 6b4520958..000000000
--- a/client/cpu/specific.pri
+++ /dev/null
@@ -1,20 +0,0 @@
-SOURCES += main.cpp\
- mainwindow.cpp \
- AddServer.cpp \
- AskKey.cpp
-
-HEADERS += mainwindow.h \
- AddServer.h \
- AskKey.h
-
-FORMS += mainwindow.ui \
- AddServer.ui \
- AskKey.ui
-
-TRANSLATIONS = $$PWD/languages/en/specific.ts \
- $$PWD/languages/fr/specific.ts
-
-ANDROID_PACKAGE_SOURCE_DIR = $$PWD/../base/android-sources
-
-DISTFILES += \
- ../base/android-sources/AndroidManifest.xml
diff --git a/client/libcatchchallenger/Api_protocol.cpp b/client/libcatchchallenger/Api_protocol.cpp
old mode 100644
new mode 100755
index fbc634d6e..49e92585e
--- a/client/libcatchchallenger/Api_protocol.cpp
+++ b/client/libcatchchallenger/Api_protocol.cpp
@@ -1,12 +1,8 @@
#include "Api_protocol.hpp"
#include "../../general/base/ProtocolVersion.hpp"
-#include "../../general/base/tinyXML2/tinyxml2.hpp"
-#include "../../general/base/tinyXML2/customtinyxml2.hpp"
-
-using namespace CatchChallenger;
-
-const unsigned char protocolHeaderToMatchLogin[] = PROTOCOL_HEADER_LOGIN;
-const unsigned char protocolHeaderToMatchGameServer[] = PROTOCOL_HEADER_GAMESERVER;
+#include "../../general/tinyXML2/tinyxml2.hpp"
+#include "../../general/tinyXML2/customtinyxml2.hpp"
+#include "../../general/sha224/sha224.hpp"
#ifdef Q_CC_GNU
//this next header is needed to change file time/date under gcc
@@ -20,12 +16,16 @@ const unsigned char protocolHeaderToMatchGameServer[] = PROTOCOL_HEADER_GAMESERV
#include "../../general/base/CommonDatapack.hpp"
#include "../../general/base/CommonSettingsCommon.hpp"
#include "../../general/base/CommonSettingsServer.hpp"
-#include "../../general/base/FacilityLib.hpp"
-#include "../../general/base/FacilityLibGeneral.hpp"
-#include "../../general/base/GeneralType.hpp"
+#include "../../general/base/cpp11addition.hpp"
//need host + port here to have datapack base
+#if ! defined (ONLYMAPRENDER)
+using namespace CatchChallenger;
+
+const unsigned char protocolHeaderToMatchLogin[] = PROTOCOL_HEADER_LOGIN;
+const unsigned char protocolHeaderToMatchGameServer[] = PROTOCOL_HEADER_GAMESERVER;
+
std::unordered_set Api_protocol::extensionAllowed;
/*std::string ""="";
@@ -55,10 +55,10 @@ Api_protocol::Api_protocol() :
extensionAllowed=std::unordered_set(v.cbegin(),v.cend());
}
+ playerExcludeIndex=255;
player_informations.recipes=NULL;
player_informations.encyclopedia_monster=NULL;
player_informations.encyclopedia_item=NULL;
- player_informations.bot_already_beaten=NULL;
stageConnexion=StageConnexion::Stage1;
resetAll();
@@ -114,7 +114,7 @@ std::map Api_protocol::getQuerySendTimeList() const
return querySendTime;
}
-std::vector Api_protocol::getEvents()
+std::vector &Api_protocol::getEvents()
{
return events;
}
@@ -130,6 +130,9 @@ void Api_protocol::errorParsingLayer(const std::string &error)
#ifdef CATCHCHALLENGER_EXTRA_CHECK
//abort();-> same behaviour on all platform
#endif
+ #ifdef CATCHCHALLENGER_ABORTIFERROR
+ abort();
+ #endif
}
void Api_protocol::messageParsingLayer(const std::string &message) const
@@ -181,16 +184,6 @@ std::string Api_protocol::getPseudo() const
return player_informations.public_informations.pseudo;
}
-uint16_t Api_protocol::getId() const
-{
- if(!getCaracterSelected())
- {
- std::cerr << "Api_protocol::getId(): !getCaracterSelected() (internal error)" << std::endl;
- return 0;
- }
- return player_informations.public_informations.simplifiedId;
-}
-
uint8_t Api_protocol::queryNumber()
{
if(lastQueryNumber.empty())
@@ -207,6 +200,11 @@ uint8_t Api_protocol::queryNumber()
bool Api_protocol::sendProtocol()
{
+ /* tcp socket call stack qtcpu800x600:
+ * Api_protocol_Qt::readForFirstHeader()
+ * Api_protocol_Qt::connectTheExternalSocketInternal()
+ * Api_protocol::connectTheExternalSocketInternal() */
+ std::cout << "Api_protocol::connectTheExternalSocketInternal()" << std::endl;
if(have_send_protocol)
{
newError("Internal problem","Api_protocol::sendProtocol() Have already send the protocol");
@@ -274,8 +272,19 @@ bool Api_protocol::protocolWrong() const
return have_send_protocol && !have_receive_protocol;
}
+void Api_protocol::hashSha224(const char * const data,const int size,char *buffer)
+{
+ SHA224 ctx = SHA224();
+ ctx.init();
+ const unsigned char * const tData=reinterpret_cast(data);
+ ctx.update(tData,size);
+ unsigned char * tBuffer=reinterpret_cast(buffer);
+ ctx.final(tBuffer);
+}
+
bool Api_protocol::tryLogin(const std::string &login, const std::string &pass)
{
+ std::cout << "Api_protocol::tryLogin()" << std::endl;
if(!have_send_protocol)
{
this->login=login;
@@ -537,17 +546,17 @@ bool Api_protocol::addCharacter(const uint8_t &charactersGroupIndex,const uint8_
std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return false;
}
- if(skinId>=CommonDatapack::commonDatapack.skins.size())
+ if(skinId>=CommonDatapack::commonDatapack.get_skins().size())
{
newError(std::string("Internal problem"),"skin provided: "+std::to_string(skinId)+" is not into skin listed");
return false;
}
- if(profileIndex>=CommonDatapack::commonDatapack.profileList.size())
+ if(profileIndex>=CommonDatapack::commonDatapack.get_profileList().size())
{
newError(std::string("Internal problem"),std::to_string(profileIndex)+">=CommonDatapack::commonDatapack.profileList.size()");
return false;
}
- const Profile &profile=CommonDatapack::commonDatapack.profileList.at(profileIndex);
+ const Profile &profile=CommonDatapack::commonDatapack.get_profileList().at(profileIndex);
if(!profile.forcedskin.empty() && !vectorcontainsAtLeastOne(profile.forcedskin,skinId))
{
newError(std::string("Internal problem"),"skin provided: "+std::to_string(skinId)+" is not into profile "+std::to_string(profileIndex)+" forced skin list");
@@ -581,6 +590,7 @@ bool Api_protocol::removeCharacter(const uint8_t &charactersGroupIndex,const uin
bool Api_protocol::selectCharacter(const uint8_t &charactersGroupIndex, const uint32_t &serverUniqueKey, const uint32_t &characterId)
{
+ std::cout << "Api_protocol::selectCharacter(uint8_t,uint32_t,uint32_t)" << std::endl;
if(characterId==0)
{
std::cerr << "Api_protocol::selectCharacter() can't have characterId==0" << std::endl;
@@ -600,6 +610,7 @@ bool Api_protocol::selectCharacter(const uint8_t &charactersGroupIndex, const ui
bool Api_protocol::selectCharacter(const uint8_t &charactersGroupIndex, const uint32_t &serverUniqueKey, const uint32_t &characterId,const uint32_t &serverIndex)
{
+ std::cout << "Api_protocol::selectCharacter(uint8_t,uint32_t,uint32_t,uint32_t)" << std::endl;
if(characterId==0)
{
std::cerr << "Api_protocol::selectCharacter() with server index can't have characterId==0" << std::endl;
@@ -620,6 +631,17 @@ bool Api_protocol::selectCharacter(const uint8_t &charactersGroupIndex, const ui
std::cerr << "character select already send, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return false;
}
+ if(serverIndex>=serverOrdenedList.size())
+ {
+ std::cerr << "server index out of bound, line: " << __FILE__ << ": " << __LINE__ << std::endl;
+ return false;
+ }
+ const uint32_t &serverUniqueKeyCheck=serverOrdenedList.at(serverIndex).uniqueKey;
+ if(serverUniqueKey!=serverUniqueKeyCheck)
+ {
+ std::cerr << "server index out of bound, line: " << __FILE__ << ": " << __LINE__ << std::endl;
+ return false;
+ }
character_select_send=true;
char buffer[1+4+4];
@@ -630,12 +652,13 @@ bool Api_protocol::selectCharacter(const uint8_t &charactersGroupIndex, const ui
memcpy(buffer+1+4,&characterIdLittleEndian,sizeof(characterIdLittleEndian));
is_logged=packOutcommingQuery(0xAC,queryNumber(),buffer,sizeof(buffer));
this->selectedServerIndex=serverIndex;
- //std::cout << "this: " << this << ", socket: " << socket << ", select char: " << characterId << ", charactersGroupIndex: " << (uint32_t)charactersGroupIndex << ", serverUniqueKey: " << serverUniqueKey << ", line: " << __FILE__ << ": " << __LINE__ << std::endl;
+ std::cout << "Api_protocol::selectCharacter(): " << this << ", select char: " << characterId << ", charactersGroupIndex: " << (uint32_t)charactersGroupIndex << ", serverUniqueKey: " << serverUniqueKey << ", line: " << __FILE__ << ": " << __LINE__ << std::endl;
return true;
}
bool Api_protocol::selectCharacter(const uint32_t &serverIndex, const uint32_t &characterId)
{
+ std::cout << "Api_protocol::selectCharacter(uint32_t,uint32_t)" << std::endl;
const std::vector &serverOrdenedList=getServerOrdenedList();
if(serverIndex>=serverOrdenedList.size())
{
@@ -712,17 +735,12 @@ void Api_protocol::monsterMoveUp(const uint8_t &number)
std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- if(number<1)
- {
- std::cerr << "the monster number start with 1, not 0, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(number>player_informations.playerMonster.size())
+ if(number>=player_informations.monsters.size())
{
std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- if(number==1)
+ if(number==0)
{
std::cerr << "can't move up the top monster, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
@@ -745,7 +763,7 @@ void Api_protocol::confirmEvolutionByPosition(const uint8_t &monsterPosition)
std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- if(monsterPosition>=player_informations.playerMonster.size())
+ if(monsterPosition>=player_informations.monsters.size())
{
std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
@@ -767,17 +785,12 @@ void Api_protocol::monsterMoveDown(const uint8_t &number)
std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- if(number<1)
- {
- std::cerr << "the monster number start with 1, not 0, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(number>player_informations.playerMonster.size())
+ if(number>=player_informations.monsters.size())
{
std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- if(number==player_informations.playerMonster.size())
+ if(((int)number-1)==(int)player_informations.monsters.size())
{
std::cerr << "can't move down the bottom monster, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
@@ -846,7 +859,7 @@ bool Api_protocol::useObjectOnMonsterByPosition(const uint16_t &object,const uin
newError(std::string("Internal problem"),std::string("in trade to change on monster"));
return false;
}
- if(monsterPosition>=player_informations.playerMonster.size())
+ if(monsterPosition>=player_informations.monsters.size())
{
std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return false;
@@ -859,56 +872,96 @@ bool Api_protocol::useObjectOnMonsterByPosition(const uint16_t &object,const uin
return true;
}
-
-void Api_protocol::wareHouseStore(const int64_t &cash, const std::vector > &items,
- const std::vector &withdrawMonsters, const std::vector &depositeMonsters)
+bool Api_protocol::wareHouseStore(const std::vector &withdrawMonsters, const std::vector &depositeMonsters)
{
if(!is_logged)
{
std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
+ return false;
}
if(!character_selected)
{
std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
+ return false;
}
- char buffer[8+2+(2+4)+4+(4)+4+(4)];
- const uint64_t &cashLittleEndian=htole64(cash);
- memcpy(buffer,&cashLittleEndian,sizeof(cashLittleEndian));
+ char buffer[
+ sizeof(uint8_t)+withdrawMonsters.size()*(sizeof(uint8_t))+
+ sizeof(uint8_t)+depositeMonsters.size()*(sizeof(uint8_t))
+ ];
+ unsigned int pos=0;
- const uint16_t &index16=htole16(items.size());
- memcpy(buffer+8,&index16,sizeof(index16));
- unsigned int index=0;
- while(index=255)
{
- const uint16_t &index16=htole16(items.at(index).first);
- memcpy(buffer+8+2+(2+4)*index,&index16,sizeof(index16));
- const uint32_t &index32=htole32(items.at(index).second);
- memcpy(buffer+8+2+(2+4)*index+2,&index32,sizeof(index32));
- index++;
+ std::cerr << "playerInformations.items.size()+withdrawItems.size()-depositeItems.size()<=255, line: " << __FILE__ << ": " << __LINE__ << std::endl;
+ return false;
+ }
+ if(playerInformations.warehouse_monsters.size()-withdrawMonsters.size()+depositeMonsters.size()>=65535)
+ {
+ std::cerr << "playerInformations.warehouse_items.size()-withdrawItems.size()+depositeItems.size()<=65535, line: " << __FILE__ << ": " << __LINE__ << std::endl;
+ return false;
}
- uint32_t index32=htole32(withdrawMonsters.size());
- memcpy(buffer+8+2+(2+4)*items.size(),&index32,sizeof(index32));
- index=0;
+ std::unordered_set alreadyMovedToWarehouse,alreadyMovedFromWarehouse;
+ int count_change=0;
+ uint8_t index8=withdrawMonsters.size();
+ memcpy(buffer+pos,&index8,sizeof(index8));
+ pos+=sizeof(uint8_t);
+ unsigned int index=0;
while(index=player_informations.warehouse_monsters.size())
+ {
+ std::cerr << "withdrawMonsters pos already moved" << std::endl;
+ return false;
+ }
+ if(alreadyMovedFromWarehouse.find(index8)!=alreadyMovedFromWarehouse.cend())
+ {
+ std::cerr << "withdrawMonsters pos already moved" << std::endl;
+ return false;
+ }
+ alreadyMovedFromWarehouse.insert(index8);
+ count_change++;
+ memcpy(buffer+pos,&index8,sizeof(index8));
+ pos+=sizeof(uint8_t);
index++;
}
- index32=htole32(depositeMonsters.size());
- memcpy(buffer+8+2+(2+4)*items.size()+4+4*withdrawMonsters.size(),&index32,sizeof(index32));
+ index8=depositeMonsters.size();
+ memcpy(buffer+pos,&index8,sizeof(index8));
+ pos+=sizeof(uint8_t);
index=0;
while(index=player_informations.monsters.size())
+ {
+ std::cerr << "withdrawMonsters pos already moved" << std::endl;
+ return false;
+ }
+ if(alreadyMovedToWarehouse.find(index8)!=alreadyMovedToWarehouse.cend())
+ {
+ std::cerr << "withdrawMonsters pos already moved" << std::endl;
+ return false;
+ }
+ alreadyMovedToWarehouse.insert(index8);
+ count_change--;
+ memcpy(buffer+pos,&index8,sizeof(index8));
+ pos+=sizeof(uint8_t);
index++;
}
+ if((player_informations.monsters.size()+count_change)>CommonSettingsCommon::commonSettingsCommon.maxPlayerMonsters)
+ {
+ std::cerr << "have more monster to withdraw than the allowed: " << CommonSettingsCommon::commonSettingsCommon.maxPlayerMonsters << std::endl;
+ return false;
+ }
+ if((player_informations.warehouse_monsters.size()-count_change)>CommonSettingsCommon::commonSettingsCommon.maxWarehousePlayerMonsters)
+ {
+ std::cerr << "have more monster to deposite than the allowed: " << CommonSettingsCommon::commonSettingsCommon.maxWarehousePlayerMonsters << std::endl;
+ return false;
+ }
- packOutcommingData(0x17,buffer,sizeof(buffer));
+ return packOutcommingData(0x17,buffer,sizeof(buffer));
}
void Api_protocol::takeAnObjectOnMap()
@@ -917,7 +970,7 @@ void Api_protocol::takeAnObjectOnMap()
packOutcommingData(0x18,NULL,0);
}
-void Api_protocol::getShopList(const uint16_t &shopId)/// \see CommonMap, std::unordered_map,std::vector, pairhash> shops;
+void Api_protocol::getShopList()/// \see CommonMap, std::unordered_map,std::vector, pairhash> shops;
{
if(!is_logged)
{
@@ -929,13 +982,10 @@ void Api_protocol::getShopList(const uint16_t &shopId)/// \see CommonMap, std::u
std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- char buffer[2];
- const uint16_t &shopIdLittleEndian=htole16(shopId);
- memcpy(buffer,&shopIdLittleEndian,sizeof(shopIdLittleEndian));
- packOutcommingQuery(0x87,queryNumber(),buffer,sizeof(buffer));
+ packOutcommingQuery(0x87,queryNumber(),NULL,0);
}
-void Api_protocol::buyObject(const uint16_t &shopId, const uint16_t &objectId, const uint32_t &quantity, const uint32_t &price)/// \see CommonMap, std::unordered_map,std::vector, pairhash> shops;
+void Api_protocol::buyObject(const uint16_t &objectId, const uint32_t &quantity, const uint32_t &price)/// \see CommonMap, std::unordered_map,std::vector, pairhash> shops;
{
if(!is_logged)
{
@@ -947,19 +997,17 @@ void Api_protocol::buyObject(const uint16_t &shopId, const uint16_t &objectId, c
std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- char buffer[2+2+4+4];
- const uint16_t &shopIdLittleEndian=htole16(shopId);
- memcpy(buffer,&shopIdLittleEndian,sizeof(shopIdLittleEndian));
+ char buffer[2+4+4];
const uint16_t &objectIdLittleEndian=htole16(objectId);
- memcpy(buffer+2,&objectIdLittleEndian,sizeof(objectIdLittleEndian));
+ memcpy(buffer,&objectIdLittleEndian,sizeof(objectIdLittleEndian));
const uint32_t &quantityLittleEndian=htole32(quantity);
- memcpy(buffer+2+2,&quantityLittleEndian,sizeof(quantityLittleEndian));
+ memcpy(buffer+2,&quantityLittleEndian,sizeof(quantityLittleEndian));
const uint32_t &priceLittleEndian=htole32(price);
- memcpy(buffer+2+2+4,&priceLittleEndian,sizeof(priceLittleEndian));
+ memcpy(buffer+2+4,&priceLittleEndian,sizeof(priceLittleEndian));
packOutcommingQuery(0x88,queryNumber(),buffer,sizeof(buffer));
}
-void Api_protocol::sellObject(const uint16_t &shopId,const uint16_t &objectId,const uint32_t &quantity,const uint32_t &price)/// \see CommonMap, std::unordered_map,std::vector, pairhash> shops;
+void Api_protocol::sellObject(const uint16_t &objectId,const uint32_t &quantity,const uint32_t &price)/// \see CommonMap, std::unordered_map,std::vector, pairhash> shops;
{
if(!is_logged)
{
@@ -971,19 +1019,17 @@ void Api_protocol::sellObject(const uint16_t &shopId,const uint16_t &objectId,co
std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
}
- char buffer[2+2+4+4];
- const uint16_t &shopIdLittleEndian=htole16(shopId);
- memcpy(buffer,&shopIdLittleEndian,sizeof(shopIdLittleEndian));
+ char buffer[2+4+4];
const uint16_t &objectIdLittleEndian=htole16(objectId);
- memcpy(buffer+2,&objectIdLittleEndian,sizeof(objectIdLittleEndian));
+ memcpy(buffer,&objectIdLittleEndian,sizeof(objectIdLittleEndian));
const uint32_t &quantityLittleEndian=htole32(quantity);
- memcpy(buffer+2+2,&quantityLittleEndian,sizeof(quantityLittleEndian));
+ memcpy(buffer+2,&quantityLittleEndian,sizeof(quantityLittleEndian));
const uint32_t &priceLittleEndian=htole32(price);
- memcpy(buffer+2+2+4,&priceLittleEndian,sizeof(priceLittleEndian));
+ memcpy(buffer+2+4,&priceLittleEndian,sizeof(priceLittleEndian));
packOutcommingQuery(0x89,queryNumber(),buffer,sizeof(buffer));
}
-void Api_protocol::getFactoryList(const uint16_t &factoryId)
+/*void Api_protocol::getFactoryList(const uint16_t &factoryId)
{
if(!is_logged)
{
@@ -1047,9 +1093,9 @@ void Api_protocol::sellFactoryResource(const uint16_t &factoryId,const uint16_t
const uint32_t &priceLittleEndian=htole32(price);
memcpy(buffer+2+2+4,&priceLittleEndian,sizeof(priceLittleEndian));
packOutcommingQuery(0x8C,queryNumber(),buffer,sizeof(buffer));
-}
+}*/
-void Api_protocol::tryEscape()
+void Api_protocol::sendTryEscape()
{
if(!is_logged)
{
@@ -1079,7 +1125,7 @@ void Api_protocol::heal()
packOutcommingData(0x0B,NULL,0);
}
-void Api_protocol::requestFight(const uint16_t &fightId)
+void Api_protocol::requestFight()
{
if(!is_logged)
{
@@ -1096,20 +1142,7 @@ void Api_protocol::requestFight(const uint16_t &fightId)
newError(std::string("Internal problem"),std::string("in trade to change on monster"));
return;
}
- if(player_informations.bot_already_beaten==NULL)
- {
- std::cerr << "player_informations.bot_already_beaten==NULL, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- abort();
- }
- if(player_informations.bot_already_beaten[fightId/8] & (1<<(7-fightId%8)))
- {
- std::cerr << "player_informations.bot_already_beaten["+std::to_string(fightId)+"], line: " << __FILE__ << ": " << __LINE__ << std::endl;
- abort();
- }
- char buffer[2];
- const uint16_t &fightIdLittleEndian=htole16(fightId);
- memcpy(buffer,&fightIdLittleEndian,sizeof(fightIdLittleEndian));
- packOutcommingData(0x0C,buffer,sizeof(buffer));
+ packOutcommingData(0x0C,NULL,0);
}
void Api_protocol::changeOfMonsterInFightByPosition(const uint8_t &monsterPosition)
@@ -1129,7 +1162,7 @@ void Api_protocol::changeOfMonsterInFightByPosition(const uint8_t &monsterPositi
newError(std::string("Internal problem"),std::string("in trade to change on monster"));
return;
}
- if(monsterPosition>=player_informations.playerMonster.size())
+ if(monsterPosition>=player_informations.monsters.size())
{
std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
@@ -1174,7 +1207,7 @@ void Api_protocol::learnSkillByPosition(const uint8_t &monsterPosition,const uin
newError(std::string("Internal problem"),std::string("in trade to change on monster"));
return;
}
- if(monsterPosition>=player_informations.playerMonster.size())
+ if(monsterPosition>=player_informations.monsters.size())
{
std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
@@ -1186,7 +1219,7 @@ void Api_protocol::learnSkillByPosition(const uint8_t &monsterPosition,const uin
packOutcommingData(0x09,buffer,sizeof(buffer));
}
-void Api_protocol::startQuest(const uint16_t &questId)
+void Api_protocol::startQuest(const CATCHCHALLENGER_TYPE_QUEST &questId)
{
if(!is_logged)
{
@@ -1204,7 +1237,7 @@ void Api_protocol::startQuest(const uint16_t &questId)
packOutcommingData(0x1B,buffer,sizeof(buffer));
}
-void Api_protocol::finishQuest(const uint16_t &questId)
+void Api_protocol::finishQuest(const CATCHCHALLENGER_TYPE_QUEST &questId)
{
if(!is_logged)
{
@@ -1222,7 +1255,7 @@ void Api_protocol::finishQuest(const uint16_t &questId)
packOutcommingData(0x1C,buffer,sizeof(buffer));
}
-void Api_protocol::cancelQuest(const uint16_t &questId)
+void Api_protocol::cancelQuest(const CATCHCHALLENGER_TYPE_QUEST &questId)
{
if(!is_logged)
{
@@ -1240,7 +1273,7 @@ void Api_protocol::cancelQuest(const uint16_t &questId)
packOutcommingData(0x1D,buffer,sizeof(buffer));
}
-void Api_protocol::nextQuestStep(const uint16_t &questId)
+void Api_protocol::nextQuestStep(const CATCHCHALLENGER_TYPE_QUEST &questId)
{
if(!is_logged)
{
@@ -1404,170 +1437,6 @@ void Api_protocol::waitingForCityCapture(const bool &cancel)
packOutcommingData(0x1F,buffer,sizeof(buffer));
}
-//market
-void Api_protocol::getMarketList()
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- packOutcommingQuery(0x8D,queryNumber(),NULL,0);
-}
-
-void Api_protocol::buyMarketObject(const uint32_t &marketObjectId, const uint32_t &quantity)
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- char buffer[1+4+4];
- buffer[0]=(uint8_t)0x01;
- const uint32_t &marketObjectIdLittleEndian=htole32(marketObjectId);
- memcpy(buffer+1,&marketObjectIdLittleEndian,sizeof(marketObjectIdLittleEndian));
- const uint32_t &quantityLittleEndian=htole32(quantity);
- memcpy(buffer+1+4,&quantityLittleEndian,sizeof(quantityLittleEndian));
- packOutcommingQuery(0x8E,queryNumber(),buffer,sizeof(buffer));
-}
-
-void Api_protocol::buyMarketMonster(const uint32_t &monsterMarketId)
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- char buffer[1+4];
- buffer[0]=(uint8_t)0x02;
- const uint32_t &monsterMarketIdLittleEndian=htole32(monsterMarketId);
- memcpy(buffer+1,&monsterMarketIdLittleEndian,sizeof(monsterMarketIdLittleEndian));
- packOutcommingQuery(0x8E,queryNumber(),buffer,sizeof(buffer));
-}
-
-void Api_protocol::putMarketObject(const uint16_t &objectId, const uint32_t &quantity, const uint64_t &price)
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- char buffer[1+2+4+8];
- buffer[0]=(uint8_t)0x01;
- const uint16_t &objectIdIdLittleEndian=htole16(objectId);
- memcpy(buffer+1,&objectIdIdLittleEndian,sizeof(objectIdIdLittleEndian));
- const uint32_t &quantityLittleEndian=htole32(quantity);
- memcpy(buffer+1+2,&quantityLittleEndian,sizeof(quantityLittleEndian));
- const uint64_t &priceLittleEndian=htole64(price);
- memcpy(buffer+1+2+4,&priceLittleEndian,sizeof(priceLittleEndian));
- packOutcommingQuery(0x8F,queryNumber(),buffer,sizeof(buffer));
-}
-
-void Api_protocol::putMarketMonsterByPosition(const uint8_t &monsterPosition,const uint64_t &price)
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(isInTrade)
- {
- newError(std::string("Internal problem"),std::string("in trade to change on monster"));
- return;
- }
- if(monsterPosition>=player_informations.playerMonster.size())
- {
- std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- char buffer[1+1+8];
- buffer[0]=(uint8_t)0x02;
- buffer[1]=monsterPosition;
- const uint64_t &priceLittleEndian=htole64(price);
- memcpy(buffer+1+1,&priceLittleEndian,sizeof(priceLittleEndian));
- packOutcommingQuery(0x8F,queryNumber(),buffer,sizeof(buffer));
-}
-
-void Api_protocol::recoverMarketCash()
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- packOutcommingQuery(0x90,queryNumber(),NULL,0);
-}
-
-void Api_protocol::withdrawMarketObject(const uint16_t &objectPosition,const uint32_t &quantity)
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- char buffer[1+2+4];
- buffer[0]=(uint8_t)0x01;
- const uint16_t &objectPositionLittleEndian=htole16(objectPosition);
- memcpy(buffer+1,&objectPositionLittleEndian,sizeof(objectPositionLittleEndian));
- const uint32_t &quantityLittleEndian=htole32(quantity);
- memcpy(buffer+1+2,&quantityLittleEndian,sizeof(quantityLittleEndian));
- packOutcommingQuery(0x91,queryNumber(),buffer,sizeof(buffer));
-}
-
-void Api_protocol::withdrawMarketMonster(const uint32_t &monsterMarketId)
-{
- if(!is_logged)
- {
- std::cerr << "is not logged, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- if(!character_selected)
- {
- std::cerr << "character not selected, line: " << __FILE__ << ": " << __LINE__ << std::endl;
- return;
- }
- char buffer[1+4];
- buffer[0]=(uint8_t)0x02;
- const uint32_t &monsterMarketIdLittleEndian=htole32(monsterMarketId);
- memcpy(buffer+1,&monsterMarketIdLittleEndian,sizeof(monsterMarketIdLittleEndian));
- packOutcommingQuery(0x91,queryNumber(),buffer,sizeof(buffer));
-}
-
void Api_protocol::collectMaturePlant()
{
if(!is_logged)
@@ -1818,7 +1687,7 @@ void Api_protocol::addMonsterByPosition(const uint8_t &monsterPosition)
newError(std::string("Internal problem"),std::string("no in trade to send monster"));
return;
}
- if(monsterPosition>=player_informations.playerMonster.size())
+ if(monsterPosition>=player_informations.monsters.size())
{
std::cerr << "the monster number greater than monster count, line: " << __FILE__ << ": " << __LINE__ << std::endl;
return;
@@ -1833,9 +1702,9 @@ Api_protocol::StageConnexion Api_protocol::stage() const
return stageConnexion;
}
-std::pair Api_protocol::getLast_number_of_player()
+std::pair Api_protocol::getLast_number_of_player()
{
- return std::pair(last_players_number,last_max_players);
+ return std::pair(last_players_number,last_max_players);
}
//to reset all
@@ -1867,26 +1736,19 @@ void Api_protocol::resetAll()
max_players=65535;
max_players_real=65535;
selectedServerIndex=-1;
- player_informations.allow.clear();
player_informations.cash=0;
player_informations.clan=0;
player_informations.clan_leader=false;
- player_informations.warehouse_cash=0;
- player_informations.warehouse_items.clear();
- player_informations.warehouse_playerMonster.clear();
player_informations.public_informations.pseudo.clear();
- player_informations.public_informations.simplifiedId=0;
player_informations.public_informations.skinId=0;
- player_informations.public_informations.speed=0;
player_informations.public_informations.type=Player_type_normal;
player_informations.public_informations.monsterId=0;
player_informations.repel_step=0;
- player_informations.playerMonster.clear();
+ player_informations.monsters.clear();
player_informations.items.clear();
player_informations.reputation.clear();
player_informations.quests.clear();
- player_informations.itemOnMap.clear();
- player_informations.plantOnMap.clear();
+ player_informations.mapData.clear();
tokenForGameServer.clear();
//to move by unit
last_step=255;
@@ -1920,11 +1782,6 @@ void Api_protocol::resetAll()
delete player_informations.encyclopedia_item;
player_informations.encyclopedia_item=NULL;
}
- if(player_informations.bot_already_beaten!=NULL)
- {
- delete player_informations.bot_already_beaten;
- player_informations.bot_already_beaten=NULL;
- }
ProtocolParsingInputOutput::reset();
flags|=0x08;
@@ -2193,6 +2050,7 @@ void Api_protocol::sslHandcheckIsFinished()
void Api_protocol::connectTheExternalSocketInternal()
{
+ std::cout << "Api_protocol::connectTheExternalSocketInternal()" << std::endl;
//continue the normal procedure
if(stageConnexion==StageConnexion::Stage1)
connectedOnLoginServer();
@@ -2419,13 +2277,6 @@ int Api_protocol::dataToPlayerMonster(const char * const data,const unsigned int
}
monster.hp=le32toh(*reinterpret_cast(data+pos));
pos+=sizeof(uint32_t);
- if((size-pos)<(int)sizeof(uint32_t))
- {
- parseError("Procotol wrong or corrupted",std::string("wrong size to get the monster sp, line: ")+std::string(__FILE__)+":"+std::to_string(__LINE__));
- return -1;
- }
- monster.sp=le32toh(*reinterpret_cast(data+pos));
- pos+=sizeof(uint32_t);
if((size-pos)<(int)sizeof(uint16_t))
{
parseError("Procotol wrong or corrupted",std::string("wrong size to get the monster captured_with, line: ")+std::string(__FILE__)+":"+std::to_string(__LINE__));
@@ -2542,7 +2393,7 @@ int Api_protocol::dataToPlayerMonster(const char * const data,const unsigned int
return pos;
}
-bool Api_protocol::setMapNumber(const unsigned int number_of_map)
+bool Api_protocol::setMapNumber(const CATCHCHALLENGER_TYPE_MAPID number_of_map)
{
if(number_of_map==0)
{
@@ -2653,18 +2504,20 @@ bool Api_protocol::haveNextStepQuestRequirements(const CatchChallenger::Quest &q
}
index++;
}
- index=0;
- while(index>& n : requirements.fights)
{
- const uint16_t &fightId=requirements.fightId.at(index);
- if(!haveBeatBot(fightId))
+ const CATCHCHALLENGER_TYPE_MAPID &mapId=n.first;
+ std::unordered_set listBots=n.second;
+ for (const auto& botFightId : listBots)
{
- #ifdef DEBUG_CLIENT_QUEST
- std::cout << "quest requirement, have not beat the bot: " << fightId << std::endl;
- #endif
- return false;
+ if(!haveBeatBot(mapId,botFightId))
+ {
+ #ifdef DEBUG_CLIENT_QUEST
+ std::cout << "quest requirement, have not beat the bot: " << fightId << std::endl;
+ #endif
+ return false;
+ }
}
- index++;
}
return true;
}
@@ -2728,9 +2581,22 @@ bool Api_protocol::haveStartQuestRequirement(const CatchChallenger::Quest &quest
return haveReputationRequirements(quest.requirements.reputation);
}
-void Api_protocol::addBeatenBotFight(const uint16_t &botFightId)
+void Api_protocol::addBeatenBotFight(const CATCHCHALLENGER_TYPE_MAPID &mapId,const CATCHCHALLENGER_TYPE_BOTID &botFightId)
{
- if(player_informations.bot_already_beaten==NULL)
- abort();
- player_informations.bot_already_beaten[botFightId/8]|=(1<<(7-botFightId%8));
+ Player_private_and_public_informations_Map &mapData=player_informations.mapData[mapId];
+ mapData.bots_beaten.insert(botFightId);
}
+
+void Api_protocol::addPlayerMonsterWarehouse(const PlayerMonster &playerMonster)
+{
+ player_informations.warehouse_monsters.push_back(playerMonster);
+}
+
+bool Api_protocol::removeMonsterWarehouseByPosition(const uint8_t &monsterPosition)
+{
+ if(monsterPosition>=player_informations.warehouse_monsters.size())
+ return false;
+ player_informations.warehouse_monsters.erase(player_informations.warehouse_monsters.cbegin()+monsterPosition);
+ return true;
+}
+#endif
diff --git a/client/libcatchchallenger/Api_protocol.hpp b/client/libcatchchallenger/Api_protocol.hpp
old mode 100644
new mode 100755
index e521ffddb..05fb3a7e0
--- a/client/libcatchchallenger/Api_protocol.hpp
+++ b/client/libcatchchallenger/Api_protocol.hpp
@@ -1,17 +1,21 @@
#ifndef CATCHCHALLENGER_PROTOCOL_H
#define CATCHCHALLENGER_PROTOCOL_H
+#if ! defined (ONLYMAPRENDER)
#include
#include