├── .gitattributes ├── .github ├── dependabot.yml └── workflows │ └── build.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── deps ├── extra │ └── mbedtls │ │ ├── psa_crypto_driver_wrappers.c │ │ └── ssl_debug_helpers_generated.c └── premake │ ├── curl.lua │ ├── gsl.lua │ ├── json.lua │ ├── l_u_a.lua │ ├── libtomcrypt.lua │ ├── libtommath.lua │ ├── mbedtls.lua │ ├── minizip.lua │ ├── mongoose.lua │ ├── mysql.lua │ ├── sol2.lua │ ├── sqlpp11.lua │ └── zlib.lua ├── generate.bat ├── premake5.lua ├── src ├── common │ └── utils │ │ ├── binary_resource.cpp │ │ ├── binary_resource.hpp │ │ ├── compression.cpp │ │ ├── compression.hpp │ │ ├── concurrency.hpp │ │ ├── cryptography.cpp │ │ ├── cryptography.hpp │ │ ├── flags.cpp │ │ ├── flags.hpp │ │ ├── http.cpp │ │ ├── http.hpp │ │ ├── io.cpp │ │ ├── io.hpp │ │ ├── memory.cpp │ │ ├── memory.hpp │ │ ├── nt.cpp │ │ ├── nt.hpp │ │ ├── string.cpp │ │ ├── string.hpp │ │ ├── thread.cpp │ │ └── thread.hpp └── server │ ├── component │ ├── command.cpp │ ├── command.hpp │ ├── console.cpp │ ├── console.hpp │ ├── scheduler.cpp │ ├── scheduler.hpp │ ├── stats.cpp │ └── stats.hpp │ ├── database │ ├── auth.cpp │ ├── auth.hpp │ ├── database.cpp │ ├── database.hpp │ ├── models │ │ ├── event_rankings.cpp │ │ ├── event_rankings.hpp │ │ ├── fobs.cpp │ │ ├── fobs.hpp │ │ ├── items.cpp │ │ ├── items.hpp │ │ ├── player_data.cpp │ │ ├── player_data.hpp │ │ ├── player_follows.cpp │ │ ├── player_follows.hpp │ │ ├── player_records.cpp │ │ ├── player_records.hpp │ │ ├── players.cpp │ │ ├── players.hpp │ │ ├── sneak_results.cpp │ │ ├── sneak_results.hpp │ │ ├── wormholes.cpp │ │ └── wormholes.hpp │ ├── table_loader.cpp │ ├── table_loader.hpp │ ├── vars.cpp │ └── vars.hpp │ ├── loader │ ├── component_interface.hpp │ ├── component_loader.cpp │ └── component_loader.hpp │ ├── main.cpp │ ├── platforms │ ├── tppstm │ │ ├── endpoints │ │ │ ├── gate │ │ │ │ ├── commands │ │ │ │ │ ├── cmd_get_svrlist.cpp │ │ │ │ │ ├── cmd_get_svrlist.hpp │ │ │ │ │ ├── cmd_get_svrtime.cpp │ │ │ │ │ ├── cmd_get_svrtime.hpp │ │ │ │ │ ├── cmd_get_urllist.cpp │ │ │ │ │ └── cmd_get_urllist.hpp │ │ │ │ ├── gate_handler.cpp │ │ │ │ └── gate_handler.hpp │ │ │ └── main │ │ │ │ ├── commands │ │ │ │ ├── cmd_abort_mother_base.cpp │ │ │ │ ├── cmd_abort_mother_base.hpp │ │ │ │ ├── cmd_active_sneak_mother_base.cpp │ │ │ │ ├── cmd_active_sneak_mother_base.hpp │ │ │ │ ├── cmd_add_follow.cpp │ │ │ │ ├── cmd_add_follow.hpp │ │ │ │ ├── cmd_approve_steam_shop.cpp │ │ │ │ ├── cmd_approve_steam_shop.hpp │ │ │ │ ├── cmd_auth_steamticket.cpp │ │ │ │ ├── cmd_auth_steamticket.hpp │ │ │ │ ├── cmd_calc_cost_fob_deploy_replace.cpp │ │ │ │ ├── cmd_calc_cost_fob_deploy_replace.hpp │ │ │ │ ├── cmd_calc_cost_time_reduction.cpp │ │ │ │ ├── cmd_calc_cost_time_reduction.hpp │ │ │ │ ├── cmd_cancel_combat_deploy.cpp │ │ │ │ ├── cmd_cancel_combat_deploy.hpp │ │ │ │ ├── cmd_cancel_combat_deploy_single.cpp │ │ │ │ ├── cmd_cancel_combat_deploy_single.hpp │ │ │ │ ├── cmd_cancel_short_pfleague.cpp │ │ │ │ ├── cmd_cancel_short_pfleague.hpp │ │ │ │ ├── cmd_check_consume_transaction.cpp │ │ │ │ ├── cmd_check_consume_transaction.hpp │ │ │ │ ├── cmd_check_defence_motherbase.cpp │ │ │ │ ├── cmd_check_defence_motherbase.hpp │ │ │ │ ├── cmd_check_server_item_correct.cpp │ │ │ │ ├── cmd_check_server_item_correct.hpp │ │ │ │ ├── cmd_check_short_pfleague_enterable.cpp │ │ │ │ ├── cmd_check_short_pfleague_enterable.hpp │ │ │ │ ├── cmd_commit_consume_transaction.cpp │ │ │ │ ├── cmd_commit_consume_transaction.hpp │ │ │ │ ├── cmd_consume_reserve.cpp │ │ │ │ ├── cmd_consume_reserve.hpp │ │ │ │ ├── cmd_create_nuclear.cpp │ │ │ │ ├── cmd_create_nuclear.hpp │ │ │ │ ├── cmd_create_player.cpp │ │ │ │ ├── cmd_create_player.hpp │ │ │ │ ├── cmd_delete_follow.cpp │ │ │ │ ├── cmd_delete_follow.hpp │ │ │ │ ├── cmd_delete_troops_list.cpp │ │ │ │ ├── cmd_delete_troops_list.hpp │ │ │ │ ├── cmd_deploy_fob_assist.cpp │ │ │ │ ├── cmd_deploy_fob_assist.hpp │ │ │ │ ├── cmd_deploy_mission.cpp │ │ │ │ ├── cmd_deploy_mission.hpp │ │ │ │ ├── cmd_destruct_nuclear.cpp │ │ │ │ ├── cmd_destruct_nuclear.hpp │ │ │ │ ├── cmd_destruct_online_nuclear.cpp │ │ │ │ ├── cmd_destruct_online_nuclear.hpp │ │ │ │ ├── cmd_develop_server_item.cpp │ │ │ │ ├── cmd_develop_server_item.hpp │ │ │ │ ├── cmd_develop_wepon.cpp │ │ │ │ ├── cmd_develop_wepon.hpp │ │ │ │ ├── cmd_elapse_combat_deploy.cpp │ │ │ │ ├── cmd_elapse_combat_deploy.hpp │ │ │ │ ├── cmd_enter_short_pfleague.cpp │ │ │ │ ├── cmd_enter_short_pfleague.hpp │ │ │ │ ├── cmd_exchange_fob_event_point.cpp │ │ │ │ ├── cmd_exchange_fob_event_point.hpp │ │ │ │ ├── cmd_exchange_league_point.cpp │ │ │ │ ├── cmd_exchange_league_point.hpp │ │ │ │ ├── cmd_exchange_league_point2.cpp │ │ │ │ ├── cmd_exchange_league_point2.hpp │ │ │ │ ├── cmd_extend_platform.cpp │ │ │ │ ├── cmd_extend_platform.hpp │ │ │ │ ├── cmd_gdpr_check.cpp │ │ │ │ ├── cmd_gdpr_check.hpp │ │ │ │ ├── cmd_get_abolition_count.cpp │ │ │ │ ├── cmd_get_abolition_count.hpp │ │ │ │ ├── cmd_get_campaign_dialog_list.cpp │ │ │ │ ├── cmd_get_campaign_dialog_list.hpp │ │ │ │ ├── cmd_get_challenge_task_rewards.cpp │ │ │ │ ├── cmd_get_challenge_task_rewards.hpp │ │ │ │ ├── cmd_get_challenge_task_target_values.cpp │ │ │ │ ├── cmd_get_challenge_task_target_values.hpp │ │ │ │ ├── cmd_get_combat_deploy_list.cpp │ │ │ │ ├── cmd_get_combat_deploy_list.hpp │ │ │ │ ├── cmd_get_combat_deploy_result.cpp │ │ │ │ ├── cmd_get_combat_deploy_result.hpp │ │ │ │ ├── cmd_get_contribute_player_list.cpp │ │ │ │ ├── cmd_get_contribute_player_list.hpp │ │ │ │ ├── cmd_get_daily_reward.cpp │ │ │ │ ├── cmd_get_daily_reward.hpp │ │ │ │ ├── cmd_get_development_progress.cpp │ │ │ │ ├── cmd_get_development_progress.hpp │ │ │ │ ├── cmd_get_entitlement_id_list.cpp │ │ │ │ ├── cmd_get_entitlement_id_list.hpp │ │ │ │ ├── cmd_get_fob_damage.cpp │ │ │ │ ├── cmd_get_fob_damage.hpp │ │ │ │ ├── cmd_get_fob_deploy_list.cpp │ │ │ │ ├── cmd_get_fob_deploy_list.hpp │ │ │ │ ├── cmd_get_fob_event_detail.cpp │ │ │ │ ├── cmd_get_fob_event_detail.hpp │ │ │ │ ├── cmd_get_fob_event_list.cpp │ │ │ │ ├── cmd_get_fob_event_list.hpp │ │ │ │ ├── cmd_get_fob_event_point_exchange_params.cpp │ │ │ │ ├── cmd_get_fob_event_point_exchange_params.hpp │ │ │ │ ├── cmd_get_fob_notice.cpp │ │ │ │ ├── cmd_get_fob_notice.hpp │ │ │ │ ├── cmd_get_fob_param.cpp │ │ │ │ ├── cmd_get_fob_param.hpp │ │ │ │ ├── cmd_get_fob_reward_list.cpp │ │ │ │ ├── cmd_get_fob_reward_list.hpp │ │ │ │ ├── cmd_get_fob_status.cpp │ │ │ │ ├── cmd_get_fob_status.hpp │ │ │ │ ├── cmd_get_fob_target_detail.cpp │ │ │ │ ├── cmd_get_fob_target_detail.hpp │ │ │ │ ├── cmd_get_fob_target_list.cpp │ │ │ │ ├── cmd_get_fob_target_list.hpp │ │ │ │ ├── cmd_get_informationlist2.cpp │ │ │ │ ├── cmd_get_informationlist2.hpp │ │ │ │ ├── cmd_get_league_result.cpp │ │ │ │ ├── cmd_get_league_result.hpp │ │ │ │ ├── cmd_get_login_param.cpp │ │ │ │ ├── cmd_get_login_param.hpp │ │ │ │ ├── cmd_get_mbcoin_remainder.cpp │ │ │ │ ├── cmd_get_mbcoin_remainder.hpp │ │ │ │ ├── cmd_get_next_maintenance.cpp │ │ │ │ ├── cmd_get_next_maintenance.hpp │ │ │ │ ├── cmd_get_online_development_progress.cpp │ │ │ │ ├── cmd_get_online_development_progress.hpp │ │ │ │ ├── cmd_get_online_prison_list.cpp │ │ │ │ ├── cmd_get_online_prison_list.hpp │ │ │ │ ├── cmd_get_own_fob_list.cpp │ │ │ │ ├── cmd_get_own_fob_list.hpp │ │ │ │ ├── cmd_get_pay_item_list.cpp │ │ │ │ ├── cmd_get_pay_item_list.hpp │ │ │ │ ├── cmd_get_pf_detail_params.cpp │ │ │ │ ├── cmd_get_pf_detail_params.hpp │ │ │ │ ├── cmd_get_pf_point_exchange_params.cpp │ │ │ │ ├── cmd_get_pf_point_exchange_params.hpp │ │ │ │ ├── cmd_get_platform_construction_progress.cpp │ │ │ │ ├── cmd_get_platform_construction_progress.hpp │ │ │ │ ├── cmd_get_player_platform_list.cpp │ │ │ │ ├── cmd_get_player_platform_list.hpp │ │ │ │ ├── cmd_get_playerlist.cpp │ │ │ │ ├── cmd_get_playerlist.hpp │ │ │ │ ├── cmd_get_previous_short_pfleague_result.cpp │ │ │ │ ├── cmd_get_previous_short_pfleague_result.hpp │ │ │ │ ├── cmd_get_purchasable_area_list.cpp │ │ │ │ ├── cmd_get_purchasable_area_list.hpp │ │ │ │ ├── cmd_get_purchase_history.cpp │ │ │ │ ├── cmd_get_purchase_history.hpp │ │ │ │ ├── cmd_get_purchase_history_num.cpp │ │ │ │ ├── cmd_get_purchase_history_num.hpp │ │ │ │ ├── cmd_get_ranking.cpp │ │ │ │ ├── cmd_get_ranking.hpp │ │ │ │ ├── cmd_get_rental_loadout_list.cpp │ │ │ │ ├── cmd_get_rental_loadout_list.hpp │ │ │ │ ├── cmd_get_resource_param.cpp │ │ │ │ ├── cmd_get_resource_param.hpp │ │ │ │ ├── cmd_get_security_info.cpp │ │ │ │ ├── cmd_get_security_info.hpp │ │ │ │ ├── cmd_get_security_product_list.cpp │ │ │ │ ├── cmd_get_security_product_list.hpp │ │ │ │ ├── cmd_get_security_setting_param.cpp │ │ │ │ ├── cmd_get_security_setting_param.hpp │ │ │ │ ├── cmd_get_server_item.cpp │ │ │ │ ├── cmd_get_server_item.hpp │ │ │ │ ├── cmd_get_server_item_list.cpp │ │ │ │ ├── cmd_get_server_item_list.hpp │ │ │ │ ├── cmd_get_shop_item_name_list.cpp │ │ │ │ ├── cmd_get_shop_item_name_list.hpp │ │ │ │ ├── cmd_get_short_pfleague_result.cpp │ │ │ │ ├── cmd_get_short_pfleague_result.hpp │ │ │ │ ├── cmd_get_sneak_target_list.cpp │ │ │ │ ├── cmd_get_sneak_target_list.hpp │ │ │ │ ├── cmd_get_steam_shop_item_list.cpp │ │ │ │ ├── cmd_get_steam_shop_item_list.hpp │ │ │ │ ├── cmd_get_troops_list.cpp │ │ │ │ ├── cmd_get_troops_list.hpp │ │ │ │ ├── cmd_get_wormhole_list.cpp │ │ │ │ ├── cmd_get_wormhole_list.hpp │ │ │ │ ├── cmd_mining_resource.cpp │ │ │ │ ├── cmd_mining_resource.hpp │ │ │ │ ├── cmd_notice_sneak_mother_base.cpp │ │ │ │ ├── cmd_notice_sneak_mother_base.hpp │ │ │ │ ├── cmd_open_steam_shop.cpp │ │ │ │ ├── cmd_open_steam_shop.hpp │ │ │ │ ├── cmd_open_wormhole.cpp │ │ │ │ ├── cmd_open_wormhole.hpp │ │ │ │ ├── cmd_purchase_first_fob.cpp │ │ │ │ ├── cmd_purchase_first_fob.hpp │ │ │ │ ├── cmd_purchase_fob.cpp │ │ │ │ ├── cmd_purchase_fob.hpp │ │ │ │ ├── cmd_purchase_nuclear_completion.cpp │ │ │ │ ├── cmd_purchase_nuclear_completion.hpp │ │ │ │ ├── cmd_purchase_online_deployment_completion.cpp │ │ │ │ ├── cmd_purchase_online_deployment_completion.hpp │ │ │ │ ├── cmd_purchase_online_development_completion.cpp │ │ │ │ ├── cmd_purchase_online_development_completion.hpp │ │ │ │ ├── cmd_purchase_platform_construction.cpp │ │ │ │ ├── cmd_purchase_platform_construction.hpp │ │ │ │ ├── cmd_purchase_resources_processing.cpp │ │ │ │ ├── cmd_purchase_resources_processing.hpp │ │ │ │ ├── cmd_purchase_security_service.cpp │ │ │ │ ├── cmd_purchase_security_service.hpp │ │ │ │ ├── cmd_purchase_send_troops_completion.cpp │ │ │ │ ├── cmd_purchase_send_troops_completion.hpp │ │ │ │ ├── cmd_purchase_wepon_development_completion.cpp │ │ │ │ ├── cmd_purchase_wepon_development_completion.hpp │ │ │ │ ├── cmd_relocate_fob.cpp │ │ │ │ ├── cmd_relocate_fob.hpp │ │ │ │ ├── cmd_rental_loadout.cpp │ │ │ │ ├── cmd_rental_loadout.hpp │ │ │ │ ├── cmd_reqauth_https.cpp │ │ │ │ ├── cmd_reqauth_https.hpp │ │ │ │ ├── cmd_reqauth_sessionsvr.cpp │ │ │ │ ├── cmd_reqauth_sessionsvr.hpp │ │ │ │ ├── cmd_request_relief.cpp │ │ │ │ ├── cmd_request_relief.hpp │ │ │ │ ├── cmd_reset_mother_base.cpp │ │ │ │ ├── cmd_reset_mother_base.hpp │ │ │ │ ├── cmd_sale_resource.cpp │ │ │ │ ├── cmd_sale_resource.hpp │ │ │ │ ├── cmd_send_boot.cpp │ │ │ │ ├── cmd_send_boot.hpp │ │ │ │ ├── cmd_send_deploy_injure.cpp │ │ │ │ ├── cmd_send_deploy_injure.hpp │ │ │ │ ├── cmd_send_heartbeat.cpp │ │ │ │ ├── cmd_send_heartbeat.hpp │ │ │ │ ├── cmd_send_ipandport.cpp │ │ │ │ ├── cmd_send_ipandport.hpp │ │ │ │ ├── cmd_send_mission_result.cpp │ │ │ │ ├── cmd_send_mission_result.hpp │ │ │ │ ├── cmd_send_nuclear.cpp │ │ │ │ ├── cmd_send_nuclear.hpp │ │ │ │ ├── cmd_send_online_challenge_task_status.cpp │ │ │ │ ├── cmd_send_online_challenge_task_status.hpp │ │ │ │ ├── cmd_send_sneak_result.cpp │ │ │ │ ├── cmd_send_sneak_result.hpp │ │ │ │ ├── cmd_send_suspicion_play_data.cpp │ │ │ │ ├── cmd_send_suspicion_play_data.hpp │ │ │ │ ├── cmd_send_troops.cpp │ │ │ │ ├── cmd_send_troops.hpp │ │ │ │ ├── cmd_set_currentplayer.cpp │ │ │ │ ├── cmd_set_currentplayer.hpp │ │ │ │ ├── cmd_set_security_challenge.cpp │ │ │ │ ├── cmd_set_security_challenge.hpp │ │ │ │ ├── cmd_sneak_mother_base.cpp │ │ │ │ ├── cmd_sneak_mother_base.hpp │ │ │ │ ├── cmd_spend_server_wallet.cpp │ │ │ │ ├── cmd_spend_server_wallet.hpp │ │ │ │ ├── cmd_start_consume_transaction.cpp │ │ │ │ ├── cmd_start_consume_transaction.hpp │ │ │ │ ├── cmd_sync_emblem.cpp │ │ │ │ ├── cmd_sync_emblem.hpp │ │ │ │ ├── cmd_sync_loadout.cpp │ │ │ │ ├── cmd_sync_loadout.hpp │ │ │ │ ├── cmd_sync_mother_base.cpp │ │ │ │ ├── cmd_sync_mother_base.hpp │ │ │ │ ├── cmd_sync_reset.cpp │ │ │ │ ├── cmd_sync_reset.hpp │ │ │ │ ├── cmd_sync_resource.cpp │ │ │ │ ├── cmd_sync_resource.hpp │ │ │ │ ├── cmd_sync_soldier_bin.cpp │ │ │ │ ├── cmd_sync_soldier_bin.hpp │ │ │ │ ├── cmd_sync_soldier_diff.cpp │ │ │ │ ├── cmd_sync_soldier_diff.hpp │ │ │ │ ├── cmd_update_session.cpp │ │ │ │ ├── cmd_update_session.hpp │ │ │ │ ├── cmd_use_pf_item.cpp │ │ │ │ ├── cmd_use_pf_item.hpp │ │ │ │ ├── cmd_use_short_pf_item.cpp │ │ │ │ └── cmd_use_short_pf_item.hpp │ │ │ │ ├── main_handler.cpp │ │ │ │ └── main_handler.hpp │ │ ├── tppstm_handler.cpp │ │ └── tppstm_handler.hpp │ └── tppstmweb │ │ ├── endpoints │ │ ├── var_handler.cpp │ │ └── var_handler.hpp │ │ ├── tppstmweb_handler.cpp │ │ └── tppstmweb_handler.hpp │ ├── resource.hpp │ ├── resource.rc │ ├── resources │ └── data │ │ ├── area_list.json │ │ ├── challenge_task_rewards.json │ │ ├── fob_deploy_list.json │ │ ├── fob_param.json │ │ ├── gdpr_check.json │ │ ├── informationlist2.json │ │ ├── item_list.json │ │ ├── login_param.json │ │ ├── mining_resource.json │ │ ├── security_setting_param.json │ │ └── steam_shop_item_list.json │ ├── scripting │ ├── engine.cpp │ └── engine.hpp │ ├── server.cpp │ ├── server.hpp │ ├── std_include.cpp │ ├── std_include.hpp │ ├── types │ ├── base_handler.cpp │ ├── base_handler.hpp │ ├── command_handler.cpp │ ├── command_handler.hpp │ ├── endpoint_handler.cpp │ ├── endpoint_handler.hpp │ ├── platform_handler.cpp │ ├── platform_handler.hpp │ ├── server.cpp │ └── server.hpp │ └── utils │ ├── config.cpp │ ├── config.hpp │ ├── encoding.cpp │ ├── encoding.hpp │ ├── http_server.cpp │ ├── http_server.hpp │ ├── resources.cpp │ ├── resources.hpp │ ├── tpp.cpp │ ├── tpp.hpp │ ├── tpp_client.cpp │ └── tpp_client.hpp └── tools └── premake5.exe /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-detectable=false -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gitsubmodule 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | open-pull-requests-limit: 10 -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | push: 5 | branches: 6 | - "*" 7 | pull_request: 8 | branches: 9 | - "*" 10 | types: [opened, synchronize, reopened] 11 | concurrency: 12 | group: ${{ github.ref }} 13 | cancel-in-progress: false 14 | jobs: 15 | build: 16 | name: Build binaries 17 | runs-on: windows-2022 18 | strategy: 19 | matrix: 20 | configuration: 21 | - Debug 22 | - Release 23 | steps: 24 | - name: Check out files 25 | uses: actions/checkout@v3 26 | with: 27 | submodules: true 28 | fetch-depth: 0 29 | lfs: false 30 | 31 | - name: Add msbuild to PATH 32 | uses: microsoft/setup-msbuild@v1.1.3 33 | 34 | - name: Generate project files 35 | run: tools/premake5 vs2022 36 | 37 | - name: Set up problem matching 38 | uses: ammaraskar/msvc-problem-matcher@master 39 | 40 | - name: Build ${{matrix.configuration}} binaries 41 | run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=x64 build/tpp-server-emulator.sln 42 | 43 | - name: Upload ${{matrix.configuration}} binaries 44 | uses: actions/upload-artifact@v3.1.0 45 | with: 46 | name: ${{matrix.configuration}} binaries 47 | path: | 48 | build/bin/x64/${{matrix.configuration}}/tpp-server-emulator.exe 49 | build/bin/x64/${{matrix.configuration}}/tpp-server-emulator.pdb 50 | build/bin/x64/${{matrix.configuration}}/libcrypto-3-x64.dll 51 | build/bin/x64/${{matrix.configuration}}/libssl-3-x64.dll 52 | build/bin/x64/${{matrix.configuration}}/libmysql.dll 53 | -------------------------------------------------------------------------------- /deps/premake/curl.lua: -------------------------------------------------------------------------------- 1 | curl = { 2 | source = path.join(dependencies.basePath, "curl"), 3 | } 4 | 5 | function curl.import() 6 | links { "curl" } 7 | 8 | filter "toolset:msc*" 9 | links { "Crypt32.lib" } 10 | filter {} 11 | 12 | curl.includes() 13 | end 14 | 15 | function curl.includes() 16 | filter "toolset:msc*" 17 | includedirs { 18 | path.join(curl.source, "include"), 19 | } 20 | 21 | defines { 22 | "CURL_STRICTER", 23 | "CURL_STATICLIB", 24 | "CURL_DISABLE_LDAP", 25 | } 26 | filter {} 27 | end 28 | 29 | function curl.project() 30 | if not os.istarget("windows") then 31 | return 32 | end 33 | 34 | project "curl" 35 | language "C" 36 | 37 | curl.includes() 38 | 39 | includedirs { 40 | path.join(curl.source, "lib"), 41 | } 42 | 43 | files { 44 | path.join(curl.source, "lib/**.c"), 45 | path.join(curl.source, "lib/**.h"), 46 | } 47 | 48 | defines { 49 | "BUILDING_LIBCURL", 50 | } 51 | 52 | filter "toolset:msc*" 53 | 54 | defines { 55 | "USE_SCHANNEL", 56 | "USE_WINDOWS_SSPI", 57 | "USE_THREADS_WIN32", 58 | } 59 | 60 | filter "toolset:not msc*" 61 | 62 | defines { 63 | "USE_GNUTLS", 64 | "USE_THREADS_POSIX", 65 | } 66 | 67 | filter {} 68 | 69 | warnings "Off" 70 | kind "StaticLib" 71 | end 72 | 73 | table.insert(dependencies, curl) -------------------------------------------------------------------------------- /deps/premake/gsl.lua: -------------------------------------------------------------------------------- 1 | gsl = { 2 | source = path.join(dependencies.basePath, "GSL"), 3 | } 4 | 5 | function gsl.import() 6 | gsl.includes() 7 | end 8 | 9 | function gsl.includes() 10 | includedirs { 11 | path.join(gsl.source, "include") 12 | } 13 | end 14 | 15 | function gsl.project() 16 | 17 | end 18 | 19 | table.insert(dependencies, gsl) 20 | -------------------------------------------------------------------------------- /deps/premake/json.lua: -------------------------------------------------------------------------------- 1 | json = { 2 | source = path.join(dependencies.basePath, "json") 3 | } 4 | 5 | function json.import() 6 | json.includes() 7 | end 8 | 9 | function json.includes() 10 | includedirs {path.join(json.source, "single_include/*")} 11 | end 12 | 13 | function json.project() 14 | 15 | end 16 | 17 | table.insert(dependencies, json) 18 | -------------------------------------------------------------------------------- /deps/premake/l_u_a.lua: -------------------------------------------------------------------------------- 1 | -- Scripts or variables named lua fuck with premake ._. 2 | l_u_a = { 3 | source = path.join(dependencies.basePath, "lua"), 4 | } 5 | 6 | function l_u_a.import() 7 | links { "lua" } 8 | l_u_a.includes() 9 | end 10 | 11 | function l_u_a.includes() 12 | includedirs { 13 | l_u_a.source 14 | } 15 | 16 | end 17 | 18 | function l_u_a.project() 19 | project "lua" 20 | language "C" 21 | 22 | l_u_a.includes() 23 | 24 | files { 25 | path.join(l_u_a.source, "*.h"), 26 | path.join(l_u_a.source, "*.c"), 27 | } 28 | 29 | removefiles { 30 | path.join(l_u_a.source, "onelua.c"), 31 | } 32 | 33 | warnings "Off" 34 | kind "StaticLib" 35 | end 36 | 37 | table.insert(dependencies, l_u_a) 38 | -------------------------------------------------------------------------------- /deps/premake/libtomcrypt.lua: -------------------------------------------------------------------------------- 1 | libtomcrypt = { 2 | source = path.join(dependencies.basePath, "libtomcrypt"), 3 | } 4 | 5 | function libtomcrypt.import() 6 | links { 7 | "libtomcrypt" 8 | } 9 | 10 | libtomcrypt.includes() 11 | end 12 | 13 | function libtomcrypt.includes() 14 | includedirs { 15 | path.join(libtomcrypt.source, "src/headers") 16 | } 17 | 18 | defines { 19 | "LTC_NO_FAST", 20 | "LTC_NO_PROTOTYPES", 21 | "LTC_NO_RSA_BLINDING", 22 | } 23 | end 24 | 25 | function libtomcrypt.project() 26 | project "libtomcrypt" 27 | language "C" 28 | 29 | libtomcrypt.includes() 30 | libtommath.import() 31 | 32 | files { 33 | path.join(libtomcrypt.source, "src/**.c"), 34 | } 35 | 36 | removefiles { 37 | path.join(libtomcrypt.source, "src/**/*tab.c"), 38 | path.join(libtomcrypt.source, "src/encauth/ocb3/**.c"), 39 | } 40 | 41 | defines { 42 | "_CRT_SECURE_NO_WARNINGS", 43 | "LTC_SOURCE", 44 | "_LIB", 45 | "USE_LTM" 46 | } 47 | 48 | removedefines { 49 | "_DLL", 50 | "_USRDLL" 51 | } 52 | 53 | linkoptions { 54 | "-IGNORE:4221" 55 | } 56 | 57 | warnings "Off" 58 | kind "StaticLib" 59 | end 60 | 61 | table.insert(dependencies, libtomcrypt) 62 | -------------------------------------------------------------------------------- /deps/premake/libtommath.lua: -------------------------------------------------------------------------------- 1 | libtommath = { 2 | source = path.join(dependencies.basePath, "libtommath"), 3 | } 4 | 5 | function libtommath.import() 6 | links { 7 | "libtommath" 8 | } 9 | 10 | libtommath.includes() 11 | end 12 | 13 | function libtommath.includes() 14 | includedirs { 15 | libtommath.source 16 | } 17 | 18 | defines { 19 | "LTM_DESC", 20 | "__STDC_IEC_559__", 21 | "MP_NO_DEV_URANDOM", 22 | } 23 | end 24 | 25 | function libtommath.project() 26 | project "libtommath" 27 | language "C" 28 | 29 | libtommath.includes() 30 | 31 | files { 32 | path.join(libtommath.source, "*.c"), 33 | } 34 | 35 | defines { 36 | "_LIB" 37 | } 38 | 39 | removedefines { 40 | "_DLL", 41 | "_USRDLL" 42 | } 43 | 44 | linkoptions { 45 | "-IGNORE:4221" 46 | } 47 | 48 | warnings "Off" 49 | kind "StaticLib" 50 | end 51 | 52 | table.insert(dependencies, libtommath) 53 | -------------------------------------------------------------------------------- /deps/premake/mbedtls.lua: -------------------------------------------------------------------------------- 1 | mbedtls = { 2 | source = path.join(dependencies.basePath, "mbedtls"), 3 | extra = path.join(dependencies.basePath, "extra/mbedtls"), 4 | } 5 | 6 | function mbedtls.import() 7 | links { "mbedtls" } 8 | mbedtls.includes() 9 | end 10 | 11 | function mbedtls.includes() 12 | includedirs { 13 | path.join(mbedtls.source, "include") 14 | } 15 | end 16 | 17 | function mbedtls.project() 18 | project "mbedtls" 19 | language "C" 20 | 21 | mbedtls.includes() 22 | 23 | files { 24 | path.join(mbedtls.source, "library/*.h"), 25 | path.join(mbedtls.source, "library/*.c"), 26 | path.join(mbedtls.extra, "*.c"), 27 | } 28 | 29 | warnings "Off" 30 | kind "StaticLib" 31 | end 32 | 33 | table.insert(dependencies, mbedtls) 34 | -------------------------------------------------------------------------------- /deps/premake/minizip.lua: -------------------------------------------------------------------------------- 1 | minizip = { 2 | source = path.join(dependencies.basePath, "zlib/contrib/minizip"), 3 | } 4 | 5 | function minizip.import() 6 | links { "minizip" } 7 | zlib.import() 8 | minizip.includes() 9 | end 10 | 11 | function minizip.includes() 12 | includedirs { 13 | minizip.source 14 | } 15 | 16 | zlib.includes() 17 | end 18 | 19 | function minizip.project() 20 | project "minizip" 21 | language "C" 22 | 23 | minizip.includes() 24 | 25 | files { 26 | path.join(minizip.source, "*.h"), 27 | path.join(minizip.source, "*.c"), 28 | } 29 | 30 | removefiles { 31 | path.join(minizip.source, "miniunz.c"), 32 | path.join(minizip.source, "minizip.c"), 33 | } 34 | 35 | defines { 36 | "_CRT_SECURE_NO_DEPRECATE", 37 | } 38 | 39 | warnings "Off" 40 | kind "StaticLib" 41 | end 42 | 43 | table.insert(dependencies, minizip) 44 | -------------------------------------------------------------------------------- /deps/premake/mongoose.lua: -------------------------------------------------------------------------------- 1 | mongoose = { 2 | source = path.join(dependencies.basePath, "mongoose"), 3 | } 4 | 5 | function mongoose.import() 6 | links "mongoose" 7 | 8 | mongoose.includes() 9 | end 10 | 11 | function mongoose.includes() 12 | includedirs { 13 | mongoose.source, 14 | } 15 | 16 | defines { 17 | "MG_TLS=1" 18 | } 19 | end 20 | 21 | function mongoose.project() 22 | project "mongoose" 23 | language "C" 24 | 25 | mongoose.includes() 26 | mbedtls.import() 27 | 28 | files { 29 | path.join(mongoose.source, "mongoose.c"), 30 | path.join(mongoose.source, "mongoose.h"), 31 | } 32 | 33 | warnings "Off" 34 | 35 | kind "StaticLib" 36 | end 37 | 38 | table.insert(dependencies, mongoose) 39 | -------------------------------------------------------------------------------- /deps/premake/mysql.lua: -------------------------------------------------------------------------------- 1 | if (os.host() ~= "windows") then 2 | error("automatic mysql installation is not supported on your os") 3 | end 4 | 5 | mysql = { 6 | source = path.join(dependencies.basePath, "mysql"), 7 | version = "8.1.0", 8 | download = "https://dev.mysql.com/get/Downloads/MySQL-8.1/mysql-8.1.0-winx64.zip", 9 | } 10 | 11 | function mysql.install() 12 | local hfile = io.open(string.format("%s/include/mysql.h", mysql.source), "r") 13 | if (hfile) then 14 | return 15 | end 16 | 17 | os.execute(string.format("mkdir \"%s\" 2> nul", mysql.source)) 18 | 19 | local folder = path.join(mysql.source, "mysql-8.1.0-winx64") 20 | local archive = path.join(mysql.source, "mysql-8.1.0-winx64.zip") 21 | 22 | print("Downloading MYSQL") 23 | os.execute(string.format("powershell -command \"curl \\\"%s\\\" -o \\\"%s\\\"\"", mysql.download, archive)) 24 | 25 | os.execute(string.format("powershell -command \"Expand-Archive -Force \\\"%s\\\" \\\"%s\\\"\"", archive, mysql.source)) 26 | os.execute(string.format("powershell -command \"mv \\\"%s/*\\\" \\\"%s\\\"\"", folder, mysql.source)) 27 | os.execute(string.format("powershell -command \"rm \\\"%s\\\"\"", archive)) 28 | os.execute(string.format("rmdir \"%s\"", folder)) 29 | end 30 | 31 | function mysql.import() 32 | linkoptions {"/DELAYLOAD:libmysql.dll"} 33 | 34 | mysql.install() 35 | mysql.includes() 36 | end 37 | 38 | function mysql.includes() 39 | includedirs { 40 | path.join(mysql.source, "include"), 41 | } 42 | end 43 | 44 | function mysql.project() 45 | project "mysql" 46 | language "C" 47 | 48 | mysql.includes() 49 | 50 | warnings "Off" 51 | kind "StaticLib" 52 | end 53 | 54 | table.insert(dependencies, mysql) 55 | -------------------------------------------------------------------------------- /deps/premake/sol2.lua: -------------------------------------------------------------------------------- 1 | sol2 = { 2 | source = path.join(dependencies.basePath, "sol2"), 3 | } 4 | 5 | function sol2.import() 6 | sol2.includes() 7 | l_u_a.import() 8 | end 9 | 10 | function sol2.includes() 11 | includedirs { 12 | path.join(sol2.source, "include") 13 | } 14 | end 15 | 16 | function sol2.project() 17 | 18 | end 19 | 20 | table.insert(dependencies, sol2) 21 | -------------------------------------------------------------------------------- /deps/premake/sqlpp11.lua: -------------------------------------------------------------------------------- 1 | sqlpp11 = { 2 | source = path.join(dependencies.basePath, "sqlpp11"), 3 | } 4 | 5 | function sqlpp11.import() 6 | sqlpp11.includes() 7 | end 8 | 9 | function sqlpp11.includes() 10 | includedirs { 11 | path.join(sqlpp11.source, "include"), 12 | path.join(dependencies.basePath, "date/include"), 13 | } 14 | end 15 | 16 | function sqlpp11.project() 17 | project "sqlpp11" 18 | language "C++" 19 | 20 | sqlpp11.includes() 21 | 22 | warnings "Off" 23 | kind "StaticLib" 24 | end 25 | 26 | table.insert(dependencies, sqlpp11) 27 | -------------------------------------------------------------------------------- /deps/premake/zlib.lua: -------------------------------------------------------------------------------- 1 | zlib = { 2 | source = path.join(dependencies.basePath, "zlib"), 3 | } 4 | 5 | function zlib.import() 6 | links { "zlib" } 7 | zlib.includes() 8 | end 9 | 10 | function zlib.includes() 11 | includedirs { 12 | zlib.source 13 | } 14 | 15 | defines { 16 | "ZLIB_CONST", 17 | } 18 | end 19 | 20 | function zlib.project() 21 | project "zlib" 22 | language "C" 23 | 24 | zlib.includes() 25 | 26 | files { 27 | path.join(zlib.source, "*.h"), 28 | path.join(zlib.source, "*.c"), 29 | } 30 | 31 | defines { 32 | "_CRT_SECURE_NO_DEPRECATE", 33 | } 34 | 35 | warnings "Off" 36 | kind "StaticLib" 37 | end 38 | 39 | table.insert(dependencies, zlib) 40 | -------------------------------------------------------------------------------- /generate.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | git submodule update --init --recursive 3 | tools\premake5 %* vs2022 -------------------------------------------------------------------------------- /src/common/utils/binary_resource.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace utils 6 | { 7 | class binary_resource 8 | { 9 | public: 10 | binary_resource(int id, std::string file); 11 | 12 | std::string get_extracted_file(bool fatal_if_overwrite_fails = false); 13 | void write_extracted_file(const bool fatal_if_overwrite_fails = false); 14 | 15 | const std::string& get_data() const; 16 | 17 | private: 18 | std::string resource_; 19 | std::string filename_; 20 | std::string path_; 21 | }; 22 | } 23 | -------------------------------------------------------------------------------- /src/common/utils/compression.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #define CHUNK 16384u 7 | 8 | namespace utils::compression 9 | { 10 | namespace zlib 11 | { 12 | std::string compress(const std::string& data); 13 | std::string decompress(const std::string& data); 14 | } 15 | 16 | namespace zip 17 | { 18 | class archive 19 | { 20 | public: 21 | void add(std::string filename, std::string data); 22 | bool write(const std::string& filename, const std::string& comment = {}); 23 | 24 | private: 25 | std::unordered_map files_; 26 | }; 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /src/common/utils/concurrency.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace utils::concurrency 6 | { 7 | template 8 | class container 9 | { 10 | public: 11 | template 12 | R access(F&& accessor) const 13 | { 14 | std::lock_guard _{mutex_}; 15 | return accessor(object_); 16 | } 17 | 18 | template 19 | R access(F&& accessor) 20 | { 21 | std::lock_guard _{mutex_}; 22 | return accessor(object_); 23 | } 24 | 25 | template 26 | R access_with_lock(F&& accessor) const 27 | { 28 | std::unique_lock lock{mutex_}; 29 | return accessor(object_, lock); 30 | } 31 | 32 | template 33 | R access_with_lock(F&& accessor) 34 | { 35 | std::unique_lock lock{mutex_}; 36 | return accessor(object_, lock); 37 | } 38 | 39 | T& get_raw() { return object_; } 40 | const T& get_raw() const { return object_; } 41 | 42 | private: 43 | mutable MutexType mutex_{}; 44 | T object_{}; 45 | }; 46 | } 47 | -------------------------------------------------------------------------------- /src/common/utils/flags.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace utils::flags 7 | { 8 | bool has_flag(const std::string& flag); 9 | std::optional get_flag(const std::string& flag); 10 | std::optional get_flag(const std::string& flag, const std::string& shortname); 11 | std::string get_flag(const std::string& flag, const std::string& shortname, 12 | const std::string& default_); 13 | } 14 | -------------------------------------------------------------------------------- /src/common/utils/http.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace utils::http 8 | { 9 | using headers = std::unordered_map; 10 | 11 | struct http_result 12 | { 13 | std::string buffer; 14 | std::uint32_t code; 15 | std::uint32_t response_code; 16 | }; 17 | 18 | std::optional get_data(const std::string& url, const headers& headers = {}, 19 | const std::function& callback = {}); 20 | std::optional post_data(const std::string& url, const std::string& data, 21 | const headers& headers = {}, const std::function& callback = {}); 22 | 23 | std::future> get_data_async(const std::string& url, const headers& headers = {}); 24 | } 25 | -------------------------------------------------------------------------------- /src/common/utils/io.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace utils::io 8 | { 9 | bool remove_file(const std::string& file); 10 | bool move_file(const std::string& src, const std::string& target); 11 | bool file_exists(const std::string& file); 12 | bool write_file(const std::string& file, const std::string& data, bool append = false); 13 | bool read_file(const std::string& file, std::string* data); 14 | std::string read_file(const std::string& file); 15 | size_t file_size(const std::string& file); 16 | bool create_directory(const std::string& directory); 17 | bool directory_exists(const std::string& directory); 18 | bool directory_is_empty(const std::string& directory); 19 | bool remove_directory(const std::string& directory); 20 | std::vector list_files(const std::string& directory); 21 | void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target); 22 | } 23 | -------------------------------------------------------------------------------- /src/common/utils/memory.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace utils 7 | { 8 | class memory final 9 | { 10 | public: 11 | class allocator final 12 | { 13 | public: 14 | ~allocator(); 15 | 16 | void clear(); 17 | 18 | void free(void* data); 19 | 20 | void free(const void* data); 21 | 22 | void* allocate(size_t length); 23 | 24 | template 25 | inline T* allocate() 26 | { 27 | return this->allocate_array(1); 28 | } 29 | 30 | template 31 | inline T* allocate_array(const size_t count = 1) 32 | { 33 | return static_cast(this->allocate(count * sizeof(T))); 34 | } 35 | 36 | bool empty() const; 37 | 38 | char* duplicate_string(const std::string& string); 39 | 40 | private: 41 | std::mutex mutex_; 42 | std::vector pool_; 43 | }; 44 | 45 | static void* allocate(size_t length); 46 | 47 | template 48 | static inline T* allocate() 49 | { 50 | return allocate_array(1); 51 | } 52 | 53 | template 54 | static inline T* allocate_array(const size_t count = 1) 55 | { 56 | return static_cast(allocate(count * sizeof(T))); 57 | } 58 | 59 | static char* duplicate_string(const std::string& string); 60 | 61 | static void free(void* data); 62 | static void free(const void* data); 63 | 64 | static bool is_set(const void* mem, char chr, size_t length); 65 | 66 | static bool is_bad_read_ptr(const void* ptr); 67 | static bool is_bad_code_ptr(const void* ptr); 68 | static bool is_rdata_ptr(void* ptr); 69 | 70 | static allocator* get_allocator(); 71 | 72 | private: 73 | static allocator mem_allocator_; 74 | }; 75 | } 76 | -------------------------------------------------------------------------------- /src/common/utils/thread.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "nt.hpp" 4 | 5 | namespace utils::thread 6 | { 7 | bool set_name(HANDLE t, const std::string& name); 8 | bool set_name(DWORD id, const std::string& name); 9 | bool set_name(std::thread& t, const std::string& name); 10 | bool set_name(const std::string& name); 11 | 12 | template 13 | std::thread create_named_thread(const std::string& name, Args&&... args) 14 | { 15 | auto t = std::thread(std::forward(args)...); 16 | set_name(t, name); 17 | return t; 18 | } 19 | 20 | std::vector get_thread_ids(); 21 | void for_each_thread(const std::function& callback); 22 | 23 | void suspend_other_threads(); 24 | void resume_other_threads(); 25 | } 26 | -------------------------------------------------------------------------------- /src/server/component/command.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace command 4 | { 5 | class params 6 | { 7 | public: 8 | params(const std::vector& tokens); 9 | 10 | std::string get(const size_t index) const; 11 | std::string operator[](const size_t index) const; 12 | 13 | size_t size() const; 14 | 15 | std::string join(const size_t index) const; 16 | 17 | private: 18 | std::vector tokens_; 19 | 20 | }; 21 | 22 | using callback = std::function; 23 | using callback_narg = std::function; 24 | 25 | void run_frame(); 26 | 27 | void execute(const std::string& cmd); 28 | void add(const std::string& name, const callback& cb); 29 | void add(const std::string& name, const callback_narg& cb); 30 | } 31 | -------------------------------------------------------------------------------- /src/server/component/console.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace console 4 | { 5 | enum console_type 6 | { 7 | con_type_print = 0, 8 | con_type_error = 1, 9 | con_type_debug = 2, 10 | con_type_warning = 3, 11 | con_type_info = 4 12 | }; 13 | 14 | void dispatch_print(const int type, const char* fmt, ...); 15 | 16 | template 17 | void print(const char* fmt, Args&&... args) 18 | { 19 | dispatch_print(con_type_print, fmt, std::forward(args)...); 20 | } 21 | 22 | template 23 | void log(const char* fmt, Args&&... args) 24 | { 25 | dispatch_print(con_type_info, fmt, std::forward(args)...); 26 | } 27 | 28 | template 29 | void warning(const char* fmt, Args&&... args) 30 | { 31 | dispatch_print(con_type_warning, fmt, std::forward(args)...); 32 | } 33 | 34 | template 35 | void error(const char* fmt, Args&&... args) 36 | { 37 | dispatch_print(con_type_error, fmt, std::forward(args)...); 38 | } 39 | 40 | template 41 | void debug([[maybe_unused]] const char* fmt, [[maybe_unused]] Args&&... args) 42 | { 43 | #ifdef DEBUG 44 | dispatch_print(con_type_debug, fmt, std::forward(args)...); 45 | #endif 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/server/component/scheduler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace scheduler 4 | { 5 | enum pipeline 6 | { 7 | async = 0, 8 | count, 9 | }; 10 | 11 | static const bool cond_continue = false; 12 | static const bool cond_end = true; 13 | 14 | void schedule(const std::function& callback, pipeline type = pipeline::async, 15 | std::chrono::milliseconds delay = 0ms); 16 | void loop(const std::function& callback, pipeline type = pipeline::async, 17 | std::chrono::milliseconds delay = 0ms); 18 | void once(const std::function& callback, pipeline type = pipeline::async, 19 | std::chrono::milliseconds delay = 0ms); 20 | } 21 | -------------------------------------------------------------------------------- /src/server/component/stats.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "loader/component_loader.hpp" 3 | 4 | #include "command.hpp" 5 | #include "scheduler.hpp" 6 | #include "../server.hpp" 7 | 8 | #include "database/database.hpp" 9 | #include "database/models/players.hpp" 10 | 11 | #include 12 | #include 13 | 14 | namespace stats 15 | { 16 | namespace 17 | { 18 | void update_window_title() 19 | { 20 | const auto total_count = database::players::get_player_count(); 21 | const auto active_count = database::players::get_online_player_count(); 22 | const auto title = std::format("tpp-server-emulator - ({} / {} active players)", active_count, total_count); 23 | SetConsoleTitle(title.data()); 24 | } 25 | } 26 | 27 | class component final : public component_interface 28 | { 29 | public: 30 | void post_start() override 31 | { 32 | update_window_title(); 33 | scheduler::loop(update_window_title, scheduler::async, 60s); 34 | 35 | command::add("player_count", [](const command::params& params) 36 | { 37 | std::chrono::seconds within = database::vars.session_timeout; 38 | 39 | if (params.size() > 1) 40 | { 41 | const auto time_str = params.get(1); 42 | within = std::chrono::seconds{std::strtoull(time_str.data(), nullptr, 10)}; 43 | } 44 | 45 | const auto total_count = database::players::get_player_count(); 46 | const auto count = database::players::get_online_player_count(within); 47 | console::log("Active players (within %llis): %lli / %lli\n", within.count(), count, total_count); 48 | }); 49 | } 50 | }; 51 | } 52 | 53 | REGISTER_COMPONENT(stats::component) 54 | -------------------------------------------------------------------------------- /src/server/component/stats.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace stats 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/server/database/auth.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace auth 4 | { 5 | struct auth_ticket_response 6 | { 7 | std::string account_id; 8 | std::string currency; 9 | std::string password; 10 | std::string smart_device_id; 11 | }; 12 | 13 | struct auth_response 14 | { 15 | bool success; 16 | std::uint64_t player_id; 17 | std::string session_id; 18 | std::string crypto_key; 19 | std::string smart_device_id; 20 | }; 21 | 22 | void initialize_lists(); 23 | void reload_lists(); 24 | 25 | std::optional authenticate_user_with_ticket(const std::string& auth_ticket, const size_t ticket_size); 26 | std::optional authenticate_user(const std::string& account_id, const std::string& password); 27 | } 28 | -------------------------------------------------------------------------------- /src/server/database/database.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "table_loader.hpp" 5 | 6 | #include "utils/config.hpp" 7 | #include "utils/resources.hpp" 8 | #include "vars.hpp" 9 | 10 | namespace sql = sqlpp::mysql; 11 | 12 | namespace database 13 | { 14 | constexpr auto max_connections = 100; 15 | 16 | using database_mutex_t = std::recursive_mutex; 17 | 18 | struct connection_t 19 | { 20 | database_t db; 21 | database_mutex_t mutex; 22 | std::chrono::high_resolution_clock::time_point start; 23 | std::chrono::high_resolution_clock::time_point last_access; 24 | }; 25 | 26 | extern std::array connection_pool; 27 | 28 | void initialize(); 29 | 30 | sql::connection_config& get_config(); 31 | 32 | template 33 | T access(F&& accessor) 34 | { 35 | for (auto& connection : connection_pool) 36 | { 37 | std::unique_lock lock(connection.mutex, std::try_to_lock); 38 | if (!lock.owns_lock()) 39 | { 40 | continue; 41 | } 42 | 43 | const auto now = std::chrono::high_resolution_clock::now(); 44 | const auto diff = now - connection.start; 45 | 46 | if (!connection.db.get() || !connection.db->is_valid() || diff >= 1h) 47 | { 48 | connection.db = std::make_unique(get_config()); 49 | connection.start = now; 50 | } 51 | 52 | connection.last_access = now; 53 | return accessor(connection.db); 54 | } 55 | 56 | throw std::runtime_error("out of connections"); 57 | } 58 | 59 | void cleanup_connections(); 60 | 61 | void run_tasks(); 62 | } 63 | -------------------------------------------------------------------------------- /src/server/database/models/player_follows.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../database.hpp" 4 | 5 | #include "players.hpp" 6 | 7 | #include "utils/tpp.hpp" 8 | 9 | namespace database::player_follows 10 | { 11 | constexpr auto max_follows = 30; 12 | 13 | class player_follow 14 | { 15 | public: 16 | DEFINE_FIELD(id, sqlpp::integer_unsigned); 17 | DEFINE_FIELD(player_id, sqlpp::integer_unsigned); 18 | DEFINE_FIELD(to_player_id, sqlpp::integer_unsigned); 19 | DEFINE_TABLE(player_follows, id_field_t, player_id_field_t, to_player_id_field_t); 20 | 21 | inline static table_t table; 22 | 23 | template 24 | player_follow(const sqlpp::result_row_t& row) 25 | { 26 | this->id_ = row.id; 27 | this->player_id_ = row.player_id; 28 | this->to_player_id_ = row.to_player_id; 29 | } 30 | 31 | std::uint64_t get_id() const 32 | { 33 | return this->id_; 34 | } 35 | 36 | std::uint64_t get_player_id() const 37 | { 38 | return this->player_id_; 39 | } 40 | 41 | std::uint64_t get_to_player_id() const 42 | { 43 | return this->to_player_id_; 44 | } 45 | 46 | 47 | private: 48 | std::uint64_t id_; 49 | std::uint64_t player_id_; 50 | std::uint64_t to_player_id_; 51 | 52 | }; 53 | 54 | bool add_follow(const std::uint64_t player_id, const std::uint64_t to_player_id); 55 | bool remove_follow(const std::uint64_t player_id, const std::uint64_t to_player_id); 56 | 57 | std::unordered_set get_follows(const std::uint64_t player_id); 58 | std::unordered_set get_followers(const std::uint64_t to_player_id); 59 | } 60 | -------------------------------------------------------------------------------- /src/server/database/table_loader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "table_loader.hpp" 4 | 5 | namespace database 6 | { 7 | tables& get_tables() 8 | { 9 | static tables tables = {}; 10 | return tables; 11 | } 12 | 13 | void register_table(std::unique_ptr&& table, int priority) 14 | { 15 | table_def def{}; 16 | def.priority = priority; 17 | def.inst = std::move(table); 18 | 19 | auto& tables = get_tables(); 20 | tables.push_back(std::move(def)); 21 | 22 | std::sort(tables.begin(), tables.end(), [](const auto& a, const auto& b) 23 | { 24 | return a.priority > b.priority; 25 | }); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/server/database/vars.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "vars.hpp" 4 | 5 | namespace database 6 | { 7 | vars_t vars{}; 8 | 9 | void initialize_vars() 10 | { 11 | vars.session_heartbeat = 1s * config::get_or("vars.session_heartbeat", vars.session_heartbeat.count()); 12 | vars.session_timeout = 1s * config::get_or("vars.session_timeout", vars.session_timeout.count()); 13 | 14 | vars.nuclear_find_probability = std::clamp(config::get_or("vars.nuclear_find_probability", vars.nuclear_find_probability), 0.f, 1.f); 15 | vars.wormhole_duration = 24h * config::get_or("vars.wormhole_duration_days", 31); 16 | 17 | vars.max_server_gmp = config::get_or("vars.max_server_gmp", vars.max_server_gmp); 18 | vars.max_local_gmp = config::get_or("vars.max_local_gmp", vars.max_local_gmp); 19 | vars.gmp_ratio = static_cast(vars.max_local_gmp) / 20 | static_cast(vars.max_server_gmp + vars.max_local_gmp); 21 | 22 | vars.item_dev_limit = config::get_or("vars.item_dev_limit", vars.item_dev_limit); 23 | 24 | vars.unlock_all_items = config::get_or("vars.unlock_all_items", vars.unlock_all_items); 25 | 26 | vars.cost_factor_generic = config::get_or("vars.cost_factor_generic", vars.cost_factor_generic); 27 | vars.cost_factor_item_dev = config::get_or("vars.cost_factor_item_dev", vars.cost_factor_generic); 28 | vars.cost_factor_platform_construction = config::get_or("vars.cost_factor_platform_construction", vars.cost_factor_generic); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/server/database/vars.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "database.hpp" 4 | 5 | #include "utils/tpp.hpp" 6 | 7 | namespace database 8 | { 9 | struct vars_t 10 | { 11 | std::chrono::seconds session_heartbeat = 60s; 12 | std::chrono::seconds session_timeout = 200s; 13 | 14 | float nuclear_find_probability = 1.f; 15 | 16 | std::chrono::hours wormhole_duration = 24h * 31; 17 | 18 | std::int32_t max_server_gmp = 25000000; 19 | std::int32_t max_local_gmp = 5000000; 20 | float gmp_ratio = 1.f; 21 | 22 | std::uint32_t item_dev_limit = 4; 23 | 24 | bool unlock_all_items = false; 25 | 26 | float cost_factor_generic = 0.01565f; 27 | float cost_factor_item_dev = 1.f; 28 | float cost_factor_platform_construction = 1.f; 29 | }; 30 | 31 | extern vars_t vars; 32 | 33 | void initialize_vars(); 34 | } 35 | -------------------------------------------------------------------------------- /src/server/loader/component_interface.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class component_interface 4 | { 5 | public: 6 | virtual ~component_interface() 7 | { 8 | 9 | } 10 | 11 | virtual void pre_start() 12 | { 13 | 14 | } 15 | 16 | 17 | virtual void post_start() 18 | { 19 | 20 | } 21 | 22 | virtual void pre_destroy() 23 | { 24 | 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /src/server/loader/component_loader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "component_interface.hpp" 3 | 4 | #include "component/console.hpp" 5 | 6 | using component_map = std::unordered_map>; 7 | 8 | class component_loader final 9 | { 10 | public: 11 | template 12 | class installer final 13 | { 14 | static_assert(std::is_base_of::value, "component has invalid base class"); 15 | 16 | public: 17 | installer(const std::string& name) 18 | { 19 | register_component(name); 20 | } 21 | }; 22 | 23 | template 24 | static T* get() 25 | { 26 | for (const auto& component_ : get_components()) 27 | { 28 | if (typeid(*component_.get()) == typeid(T)) 29 | { 30 | return reinterpret_cast(component_.get()); 31 | } 32 | } 33 | 34 | return nullptr; 35 | } 36 | 37 | template 38 | static void register_component(const std::string& name) 39 | { 40 | console::debug("Registering component \"%s\"\n", name.data()); 41 | get_components().insert(std::make_pair(name, std::make_unique())); 42 | } 43 | 44 | static void pre_start(); 45 | static void post_start(); 46 | static void pre_destroy(); 47 | 48 | private: 49 | static component_map& get_components(); 50 | 51 | }; 52 | 53 | #define REGISTER_COMPONENT(name) \ 54 | namespace \ 55 | { \ 56 | static component_loader::installer __component(#name); \ 57 | } 58 | -------------------------------------------------------------------------------- /src/server/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include "server.hpp" 6 | #include "utils/config.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace 14 | { 15 | std::unordered_map embedded_dlls = 16 | { 17 | {"libmysql.dll", RESOURCE_DLL_LIBMYSQL}, 18 | {"libcrypto-3-x64.dll", RESOURCE_DLL_LIBCRYPTO}, 19 | {"libssl-3-x64.dll", RESOURCE_DLL_LIBSSL}, 20 | }; 21 | 22 | void write_dlls() 23 | { 24 | const auto use_tmp_folder = config::get("use_tmp_folder"); 25 | 26 | if (use_tmp_folder) 27 | { 28 | const auto temp_folder = utils::nt::get_temp_folder(); 29 | SetDllDirectory(temp_folder.data()); 30 | } 31 | 32 | for (const auto& [name, id] : embedded_dlls) 33 | { 34 | auto binary_resource = utils::binary_resource{id, name}; 35 | if (use_tmp_folder) 36 | { 37 | binary_resource.write_extracted_file(); 38 | } 39 | else 40 | { 41 | utils::io::write_file(name, binary_resource.get_data()); 42 | } 43 | } 44 | } 45 | 46 | void set_working_dir() 47 | { 48 | const auto default_path = std::filesystem::current_path().generic_string(); 49 | const auto working_dir_flag = utils::flags::get_flag("working_dir"); 50 | const auto working_dir = working_dir_flag.value_or(default_path); 51 | 52 | std::filesystem::current_path(working_dir); 53 | console::log("Working dir: %s\n", working_dir.data()); 54 | } 55 | } 56 | 57 | int main() 58 | { 59 | set_working_dir(); 60 | write_dlls(); 61 | tpp::start_server(); 62 | return 0; 63 | } 64 | 65 | int __stdcall WinMain(HINSTANCE, HINSTANCE, PSTR, int) 66 | { 67 | return main(); 68 | } 69 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/gate/commands/cmd_get_svrlist.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_svrlist.hpp" 4 | 5 | namespace tpp 6 | { 7 | nlohmann::json cmd_get_svrlist::execute(nlohmann::json& data, const std::optional&) 8 | { 9 | nlohmann::json result; 10 | 11 | result["result"] = "NOERR"; 12 | result["server_num"] = 0; 13 | result["svrlist"] = nlohmann::json::array(); 14 | result["xuid"] = {}; 15 | 16 | return result; 17 | } 18 | } -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/gate/commands/cmd_get_svrlist.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_svrlist : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/gate/commands/cmd_get_svrtime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_svrtime.hpp" 4 | 5 | #define HOSTNAME "http://localhost:80/" 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_svrtime::execute(nlohmann::json& data, const std::optional&) 10 | { 11 | nlohmann::json result; 12 | 13 | result["result"] = "NOERR"; 14 | result["date"] = std::time(nullptr); 15 | 16 | return result; 17 | } 18 | } -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/gate/commands/cmd_get_svrtime.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_svrtime : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/gate/commands/cmd_get_urllist.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_urllist : public command_handler 8 | { 9 | public: 10 | cmd_get_urllist(); 11 | 12 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/gate/gate_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/endpoint_handler.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | class gate_handler : public endpoint_handler 10 | { 11 | public: 12 | gate_handler(); 13 | 14 | std::optional decrypt_request(const std::string& data, std::optional& player) override; 15 | bool verify_request(const nlohmann::json& request) override; 16 | std::optional encrypt_response(const nlohmann::json& request, nlohmann::json data, 17 | const std::optional& player) override; 18 | 19 | private: 20 | utils::cryptography::blowfish blow_; 21 | 22 | }; 23 | } -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_abort_mother_base.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_abort_mother_base.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/player_records.hpp" 7 | #include "database/models/players.hpp" 8 | #include "database/models/sneak_results.hpp" 9 | 10 | #include 11 | 12 | namespace tpp 13 | { 14 | nlohmann::json cmd_abort_mother_base::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | nlohmann::json result; 17 | result["result"] = "NOERR"; 18 | 19 | if (!player.has_value()) 20 | { 21 | return error(ERR_INVALID_SESSION); 22 | } 23 | 24 | database::players::abort_mother_base(player->get_id()); 25 | 26 | return result; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_abort_mother_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_abort_mother_base : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_active_sneak_mother_base.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_active_sneak_mother_base.hpp" 4 | 5 | #include "database/models/items.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_active_sneak_mother_base::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | if (!player.has_value()) 15 | { 16 | return error(ERR_INVALID_SESSION); 17 | } 18 | 19 | const auto& mother_base_id_j = data["mother_base_id"]; 20 | if (!mother_base_id_j.is_number_unsigned()) 21 | { 22 | return error(ERR_DATABASE); 23 | } 24 | 25 | const auto mother_base_id = mother_base_id_j.get(); 26 | const auto active_sneak = database::players::find_active_sneak_from_player(player->get_id()); 27 | 28 | if (!active_sneak.has_value() || active_sneak->get_fob_id() != mother_base_id) 29 | { 30 | return error(ERR_DATABASE); 31 | } 32 | 33 | if (!database::players::set_active_sneak(player->get_id(), active_sneak->get_fob_id(), active_sneak->get_owner_id(), 34 | active_sneak->get_platform(), active_sneak->get_mode(), database::players::status_in_game, active_sneak->is_sneak(), false)) 35 | { 36 | return error(ERR_DATABASE); 37 | } 38 | 39 | return error(NOERR); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_active_sneak_mother_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_active_sneak_mother_base : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_add_follow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_add_follow : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | bool needs_player() override; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_approve_steam_shop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_approve_steam_shop.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_approve_steam_shop::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_approve_steam_shop.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_approve_steam_shop : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_auth_steamticket.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_auth_steamticket : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_calc_cost_fob_deploy_replace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_calc_cost_fob_deploy_replace.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | nlohmann::json cmd_calc_cost_fob_deploy_replace::execute(nlohmann::json& data, const std::optional& player) 12 | { 13 | nlohmann::json result; 14 | result["cost"] = 0; 15 | return result; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_calc_cost_fob_deploy_replace.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_calc_cost_fob_deploy_replace : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_calc_cost_time_reduction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_calc_cost_time_reduction.hpp" 4 | 5 | #include "database/models/player_data.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_calc_cost_time_reduction::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | const auto& kind_j = data["kind"]; 22 | const auto& remaining_time_j = data["remaining_time"]; 23 | 24 | if (!kind_j.is_string() || !remaining_time_j.is_number_integer()) 25 | { 26 | return error(ERR_INVALIDARG); 27 | } 28 | 29 | const auto kind = kind_j.get(); 30 | const auto remaining_time = remaining_time_j.get(); 31 | 32 | const auto get_cost = [&] 33 | { 34 | if (kind == "PLATFORM_CONSTRUCTION") 35 | { 36 | return utils::tpp::calculate_mb_coins(remaining_time, database::vars.cost_factor_platform_construction); 37 | } 38 | 39 | return utils::tpp::calculate_mb_coins(remaining_time, database::vars.cost_factor_generic); 40 | }; 41 | 42 | result["cost"] = get_cost(); 43 | 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_calc_cost_time_reduction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_calc_cost_time_reduction : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_cancel_combat_deploy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_cancel_combat_deploy.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_cancel_combat_deploy::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_cancel_combat_deploy.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_cancel_combat_deploy : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_cancel_combat_deploy_single.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_cancel_combat_deploy_single.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_cancel_combat_deploy_single::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_cancel_combat_deploy_single.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_cancel_combat_deploy_single : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_cancel_short_pfleague.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_cancel_short_pfleague.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_cancel_short_pfleague::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_cancel_short_pfleague.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_cancel_short_pfleague : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_consume_transaction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_check_consume_transaction.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_check_consume_transaction::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_consume_transaction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_check_consume_transaction : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_defence_motherbase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_check_defence_motherbase.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/player_records.hpp" 7 | #include "database/models/players.hpp" 8 | 9 | #include 10 | 11 | namespace tpp 12 | { 13 | nlohmann::json cmd_check_defence_motherbase::execute(nlohmann::json& data, const std::optional& player) 14 | { 15 | nlohmann::json result; 16 | result["result"] = "NOERR"; 17 | 18 | if (!player.has_value()) 19 | { 20 | return error(ERR_INVALID_SESSION); 21 | } 22 | 23 | const auto& owner_player_id_j = data["owner_player_id"]; 24 | if (!owner_player_id_j.is_number_unsigned()) 25 | { 26 | return error(ERR_INVALIDARG); 27 | } 28 | 29 | const auto owner_player_id = owner_player_id_j.get(); 30 | const auto active_sneak = database::players::find_active_sneak(owner_player_id, true); 31 | const auto active_sneak_defense = database::players::find_active_sneak(owner_player_id, false); 32 | 33 | if (!active_sneak.has_value()) 34 | { 35 | result["check_result"] = 0; 36 | return result; 37 | } 38 | 39 | if (active_sneak.has_value() && active_sneak_defense.has_value()) 40 | { 41 | result["check_result"] = 1; 42 | return result; 43 | } 44 | 45 | if (active_sneak.has_value() && !active_sneak_defense.has_value()) 46 | { 47 | result["check_result"] = 2; 48 | return result; 49 | } 50 | 51 | return result; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_defence_motherbase.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_check_defence_motherbase : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_server_item_correct.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_check_server_item_correct.hpp" 4 | 5 | #include "database/models/items.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_check_server_item_correct::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | const auto& item_list = data["item_list"]; 22 | if (!item_list.is_array()) 23 | { 24 | return result; 25 | } 26 | 27 | auto check_result = 0; 28 | 29 | const auto server_item_list = database::items::get_item_list(player->get_id()); 30 | for (auto i = 0; i < item_list.size(); i++) 31 | { 32 | if (!item_list[i].is_number_unsigned()) 33 | { 34 | continue; 35 | } 36 | 37 | const auto item_id = item_list[i].get(); 38 | const auto& iter = server_item_list.find(item_id); 39 | if (iter != server_item_list.end() && iter->second.get_develop() != database::items::developed) 40 | { 41 | check_result = 1; 42 | break; 43 | } 44 | } 45 | 46 | result["check_result"] = check_result; 47 | 48 | return error(NOERR); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_server_item_correct.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_check_server_item_correct : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_short_pfleague_enterable.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_check_short_pfleague_enterable.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_check_short_pfleague_enterable::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_check_short_pfleague_enterable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_check_short_pfleague_enterable : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_commit_consume_transaction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_commit_consume_transaction.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_commit_consume_transaction::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_commit_consume_transaction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_commit_consume_transaction : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_consume_reserve.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_consume_reserve.hpp" 4 | 5 | #include "database/models/player_data.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_consume_reserve::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | return result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_consume_reserve.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_consume_reserve : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_create_nuclear.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_create_nuclear.hpp" 4 | 5 | #include "database/models/items.hpp" 6 | #include "database/models/player_data.hpp" 7 | 8 | namespace tpp 9 | { 10 | nlohmann::json create_nuclear(const std::optional& player) 11 | { 12 | const auto player_data = database::player_data::find(player->get_id()); 13 | if (!player_data.get()) 14 | { 15 | return error(ERR_INVALIDARG); 16 | } 17 | 18 | const auto item = database::items::get_item(player->get_id(), database::items::nuclear); 19 | if (item.get_develop() != database::items::developed) 20 | { 21 | return error(ERR_INVALIDARG); 22 | } 23 | 24 | if (!database::items::remove(player->get_id(), database::items::nuclear)) 25 | { 26 | return error(ERR_DATABASE); 27 | } 28 | 29 | database::player_data::resource_arrays_t resources{}; 30 | player_data->copy_resources(resources); 31 | 32 | const auto inc = resources[database::player_data::processed_server][database::player_data::nuclear] + 1; 33 | const auto capped = database::player_data::cap_resource_value(database::player_data::processed_server, database::player_data::nuclear, inc); 34 | resources[database::player_data::processed_server][database::player_data::nuclear] = capped; 35 | 36 | database::player_data::set_resources(player->get_id(), resources, player_data->get_local_gmp(), player_data->get_server_gmp()); 37 | 38 | return error(NOERR); 39 | } 40 | 41 | nlohmann::json cmd_create_nuclear::execute(nlohmann::json& data, const std::optional& player) 42 | { 43 | return create_nuclear(player); 44 | } 45 | 46 | bool cmd_create_nuclear::needs_player() 47 | { 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_create_nuclear.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | nlohmann::json create_nuclear(const std::optional& player); 8 | 9 | class cmd_create_nuclear : public command_handler 10 | { 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | bool needs_player() override; 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_create_player.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_create_player.hpp" 4 | 5 | #include "database/auth.hpp" 6 | 7 | #include "database/models/players.hpp" 8 | #include "database/models/player_records.hpp" 9 | #include "database/models/player_data.hpp" 10 | #include "database/models/event_rankings.hpp" 11 | 12 | #include 13 | 14 | namespace tpp 15 | { 16 | nlohmann::json cmd_create_player::execute(nlohmann::json& data, const std::optional& player) 17 | { 18 | nlohmann::json result; 19 | result["xuid"] = {}; 20 | 21 | if (!player.has_value()) 22 | { 23 | return error(ERR_INVALID_SESSION); 24 | } 25 | 26 | database::player_records::find_or_create(player->get_id()); 27 | database::player_data::find_or_create(player->get_id()); 28 | database::event_rankings::create_entries(player->get_id()); 29 | 30 | result["player_id"] = player->get_id(); 31 | result["result"] = "NOERR"; 32 | 33 | return result; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_create_player.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_create_player : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_delete_follow.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_delete_follow.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | #include "database/models/player_follows.hpp" 7 | 8 | namespace tpp 9 | { 10 | nlohmann::json cmd_delete_follow::execute(nlohmann::json& data, const std::optional& player) 11 | { 12 | const auto& player_id_j = data["player_id"]; 13 | 14 | if (!player_id_j.is_number_unsigned()) 15 | { 16 | return error(ERR_INVALIDARG); 17 | } 18 | 19 | const auto to_player_id = player_id_j.get(); 20 | if (!database::players::exists(to_player_id)) 21 | { 22 | return error(ERR_PLAYER_NOTFOUND); 23 | } 24 | 25 | if (to_player_id == player->get_id()) 26 | { 27 | return error(NOERR); 28 | } 29 | 30 | if (!database::player_follows::remove_follow(player->get_id(), to_player_id)) 31 | { 32 | return error(ERR_DATABASE); 33 | } 34 | 35 | return error(NOERR); 36 | } 37 | 38 | bool cmd_delete_follow::needs_player() 39 | { 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_delete_follow.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_delete_follow : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | bool needs_player() override; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_delete_troops_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_delete_troops_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_delete_troops_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_delete_troops_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_delete_troops_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_deploy_fob_assist.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_deploy_fob_assist : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_deploy_mission.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_deploy_mission.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_deploy_mission::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_deploy_mission.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_deploy_mission : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_destruct_nuclear.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_destruct_nuclear.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_destruct_nuclear::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_destruct_nuclear.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_destruct_nuclear : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_destruct_online_nuclear.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_destruct_online_nuclear.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_destruct_online_nuclear::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_destruct_online_nuclear.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_destruct_online_nuclear : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_develop_server_item.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | #include "../main_handler.hpp" 6 | 7 | namespace tpp 8 | { 9 | class cmd_develop_server_item : public command_handler 10 | { 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_develop_wepon.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_develop_wepon.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_develop_wepon::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_develop_wepon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_develop_wepon : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_elapse_combat_deploy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_elapse_combat_deploy.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_elapse_combat_deploy::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_elapse_combat_deploy.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_elapse_combat_deploy : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_enter_short_pfleague.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_enter_short_pfleague.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_enter_short_pfleague::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_enter_short_pfleague.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_enter_short_pfleague : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_exchange_fob_event_point.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_exchange_fob_event_point.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_exchange_fob_event_point::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_exchange_fob_event_point.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_exchange_fob_event_point : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_exchange_league_point.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_exchange_league_point.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_exchange_league_point::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_exchange_league_point.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_exchange_league_point : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_exchange_league_point2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_exchange_league_point2.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_exchange_league_point2::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_exchange_league_point2.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_exchange_league_point2 : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_extend_platform.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_extend_platform.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_extend_platform::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_extend_platform.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_extend_platform : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_gdpr_check.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_gdpr_check.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | cmd_gdpr_check::cmd_gdpr_check() 10 | { 11 | this->list_ = resource(RESOURCE_GDPR_CHECK); 12 | } 13 | 14 | nlohmann::json cmd_gdpr_check::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | return this->list_; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_gdpr_check.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_gdpr_check : public command_handler 8 | { 9 | public: 10 | cmd_gdpr_check(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_abolition_count.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_abolition_count.hpp" 4 | 5 | #include "database/models/player_data.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | nlohmann::json cmd_get_abolition_count::execute(nlohmann::json& data, const std::optional& player) 12 | { 13 | nlohmann::json result; 14 | result["result"] = "NOERR"; 15 | result["count"] = 3; 16 | result["date"] = std::time(nullptr); 17 | result["max"] = std::numeric_limits::max(); 18 | result["num"] = database::player_data::get_nuke_count(); 19 | result["status"] = 0; 20 | 21 | return result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_abolition_count.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_abolition_count : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_campaign_dialog_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_campaign_dialog_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_campaign_dialog_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_campaign_dialog_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_campaign_dialog_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_challenge_task_rewards.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_challenge_task_rewards.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | cmd_get_challenge_task_rewards::cmd_get_challenge_task_rewards() 10 | { 11 | this->list_ = resource(RESOURCE_CHALLENGE_TASK_REWARDS); 12 | } 13 | 14 | nlohmann::json cmd_get_challenge_task_rewards::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | return this->list_; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_challenge_task_rewards.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_challenge_task_rewards : public command_handler 8 | { 9 | public: 10 | cmd_get_challenge_task_rewards(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_challenge_task_target_values.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_challenge_task_target_values.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_challenge_task_target_values::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | 13 | result["result"] = "NOERR"; 14 | result["espionage_rating_grade"] = 0; 15 | result["fob_defense_success_count"] = 0; 16 | result["fob_deploy_to_supporters_emergency_count"] = 0; 17 | result["fob_sneak_count"] = 0; 18 | result["fob_sneak_success_count"] = 0; 19 | result["fob_supporting_user_count"] = 0; 20 | result["pf_rating_defense_force"] = 0; 21 | result["pf_rating_defense_life"] = 0; 22 | result["pf_rating_offence_force"] = 0; 23 | result["pf_rating_offence_life"] = 0; 24 | result["pf_rating_rank"] = 0; 25 | result["total_development_grade"] = 0; 26 | result["total_fob_security_level"] = 0; 27 | 28 | return result; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_challenge_task_target_values.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_challenge_task_target_values : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_combat_deploy_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_combat_deploy_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_combat_deploy_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_combat_deploy_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_combat_deploy_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_combat_deploy_result.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_combat_deploy_result.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | #include "database/models/player_records.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_get_combat_deploy_result::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | result["xuid"] = {}; 16 | 17 | if (!player.has_value()) 18 | { 19 | return error(ERR_INVALID_SESSION); 20 | } 21 | 22 | result["result_list"] = nlohmann::json::array(); 23 | result["result_num"] = 0; 24 | result["result"] = "NOERR"; 25 | 26 | return result; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_combat_deploy_result.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_combat_deploy_result : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_contribute_player_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_contribute_player_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_contribute_player_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_contribute_player_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_contribute_player_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_daily_reward.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_daily_reward.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/players.hpp" 7 | #include "database/models/player_data.hpp" 8 | #include "database/models/player_records.hpp" 9 | 10 | #include 11 | 12 | namespace tpp 13 | { 14 | nlohmann::json cmd_get_daily_reward::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | nlohmann::json result; 17 | 18 | if (!player.has_value()) 19 | { 20 | return error(ERR_INVALID_SESSION); 21 | } 22 | 23 | result["count"] = 0; 24 | result["league_list"] = nlohmann::json::array(); 25 | result["league_num"] = 0; 26 | result["personal_list"] = nlohmann::json::array(); 27 | result["personal_num"] = 0; 28 | result["reward_type"] = 0; 29 | result["section"] = 0; 30 | 31 | return result; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_daily_reward.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_daily_reward : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_development_progress.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_development_progress.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_development_progress::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_development_progress.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_development_progress : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_entitlement_id_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_entitlement_id_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_entitlement_id_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_entitlement_id_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_entitlement_id_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_damage.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_damage.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_fob_damage::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | 13 | result["damage"]["gmp"] = 0; 14 | result["damage"]["staff"] = 0; 15 | result["damage"]["resource"]["biotic_resource"] = 0; 16 | result["damage"]["resource"]["common_metal"] = 0; 17 | result["damage"]["resource"]["fuel_resource"] = 0; 18 | result["damage"]["resource"]["minor_metal"] = 0; 19 | result["damage"]["resource"]["precious_metal"] = 0; 20 | 21 | return result; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_damage.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_damage : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_deploy_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_deploy_list.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | cmd_get_fob_deploy_list::cmd_get_fob_deploy_list() 12 | { 13 | this->list_ = resource(RESOURCE_FOB_DEPLOY_LIST); 14 | } 15 | 16 | nlohmann::json cmd_get_fob_deploy_list::execute(nlohmann::json& data, const std::optional& player) 17 | { 18 | return this->list_; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_deploy_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_deploy_list : public command_handler 8 | { 9 | public: 10 | cmd_get_fob_deploy_list(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_event_detail.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_event_detail.hpp" 4 | 5 | #include "database/models/sneak_results.hpp" 6 | #include "database/models/player_records.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_get_fob_event_detail::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | const auto& event_index_j = data["event_index"]; 22 | if (!event_index_j.is_number_unsigned()) 23 | { 24 | return error(ERR_INVALIDARG); 25 | } 26 | 27 | const auto event_id = event_index_j.get(); 28 | auto sneak_result = database::sneak_results::get_sneak_result(player->get_id(), event_index_j); 29 | 30 | if (!sneak_result.has_value()) 31 | { 32 | return error(ERR_DATABASE); 33 | } 34 | 35 | auto& sneak_data = sneak_result->get_data(); 36 | 37 | const auto attacker_record = database::player_records::find(sneak_result->get_player_id()); 38 | if (!attacker_record.has_value()) 39 | { 40 | return error(ERR_DATABASE); 41 | } 42 | 43 | result["event_index"] = event_id; 44 | result["event"] = sneak_data["event"]; 45 | result["event"]["attacker_league_grade"] = attacker_record->get_league_grade(); 46 | result["event"]["attacker_sneak_grade"] = attacker_record->get_fob_grade(); 47 | result["event"]["regist_date"] = sneak_result->get_date(); 48 | 49 | return result; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_event_detail.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_event_detail : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_event_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_event_list.hpp" 4 | 5 | #include "database/models/sneak_results.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | nlohmann::json cmd_get_fob_event_list::execute(nlohmann::json& data, const std::optional& player) 12 | { 13 | nlohmann::json result; 14 | 15 | if (!player.has_value()) 16 | { 17 | return error(ERR_INVALID_SESSION); 18 | } 19 | 20 | auto sneak_results = database::sneak_results::get_sneak_results(player->get_id(), 10); 21 | 22 | for (auto i = 0u; i < sneak_results.size(); i++) 23 | { 24 | auto& sneak = sneak_results[i]; 25 | auto& sneak_data = sneak.get_data(); 26 | 27 | const auto layout_code = sneak_data["event"]["layout_code"].get(); 28 | 29 | result["event_list"][i]["attacker_id"] = sneak.get_player_id(); 30 | result["event_list"][i]["event_index"] = sneak.get_id(); 31 | result["event_list"][i]["fob_index"] = sneak.get_fob_index(); 32 | result["event_list"][i]["is_win"] = sneak.is_win(); 33 | result["event_list"][i]["cluster"] = sneak.get_platform(); 34 | result["event_list"][i]["layout_code"] = layout_code; 35 | } 36 | 37 | result["event_num"] = sneak_results.size(); 38 | 39 | return result; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_event_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_event_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_event_point_exchange_params.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_event_point_exchange_params.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_fob_event_point_exchange_params::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_event_point_exchange_params.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_event_point_exchange_params : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_notice.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_notice : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_param.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_param.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | cmd_get_fob_param::cmd_get_fob_param() 10 | { 11 | this->list_ = resource(RESOURCE_FOB_PARAM); 12 | } 13 | 14 | nlohmann::json cmd_get_fob_param::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | return this->list_; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_param.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_param : public command_handler 8 | { 9 | public: 10 | cmd_get_fob_param(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_reward_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_reward_list.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/players.hpp" 7 | #include "database/models/player_data.hpp" 8 | #include "database/models/player_records.hpp" 9 | 10 | #include 11 | 12 | namespace tpp 13 | { 14 | nlohmann::json cmd_get_fob_reward_list::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | nlohmann::json result; 17 | 18 | if (!player.has_value()) 19 | { 20 | return error(ERR_INVALID_SESSION); 21 | } 22 | 23 | result["reward_count"] = 0; 24 | result["version"] = 0; 25 | result["reward_info"] = nlohmann::json::array(); 26 | 27 | return result; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_reward_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_reward_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_status.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_fob_status.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/player_records.hpp" 7 | #include "database/models/players.hpp" 8 | 9 | #include 10 | 11 | namespace tpp 12 | { 13 | nlohmann::json cmd_get_fob_status::execute(nlohmann::json& data, const std::optional& player) 14 | { 15 | nlohmann::json result; 16 | 17 | if (!player.has_value()) 18 | { 19 | return error(ERR_INVALID_SESSION); 20 | } 21 | 22 | const auto stats = database::player_records::find(player->get_id()); 23 | if (!stats.has_value()) 24 | { 25 | return error(ERR_INVALIDARG); 26 | } 27 | 28 | const auto active_sneak = database::players::find_active_sneak(player->get_id(), true, true); 29 | 30 | result["result"] = "NOERR"; 31 | result["fob_index"] = -1; 32 | result["is_rescue"] = static_cast(active_sneak.has_value()); 33 | result["is_reward"] = 0; 34 | result["kill_count"] = 0; 35 | result["sneak_mode"] = -1; 36 | 37 | result["record"]["defense"]["win"] = stats->get_defense_win(); 38 | result["record"]["defense"]["lose"] = stats->get_defense_lose(); 39 | result["record"]["insurance"] = 0; 40 | result["record"]["score"] = stats->get_fob_point(); 41 | result["record"]["shield_date"] = stats->get_shield_date(); 42 | result["record"]["sneak"]["win"] = stats->get_sneak_win(); 43 | result["record"]["sneak"]["lose"] = stats->get_sneak_lose(); 44 | 45 | return result; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_status.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_status : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_target_detail.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_target_detail : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_fob_target_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_fob_target_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_informationlist2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_informationlist2.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | cmd_get_informationlist2::cmd_get_informationlist2() 10 | { 11 | this->list_ = resource(RESOURCE_INFORMATIONLIST2); 12 | } 13 | 14 | nlohmann::json cmd_get_informationlist2::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | return this->list_; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_informationlist2.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_informationlist2 : public command_handler 8 | { 9 | public: 10 | cmd_get_informationlist2(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_league_result.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_league_result.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/players.hpp" 7 | #include "database/models/player_data.hpp" 8 | #include "database/models/player_records.hpp" 9 | 10 | #include 11 | 12 | namespace tpp 13 | { 14 | nlohmann::json cmd_get_league_result::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | nlohmann::json result; 17 | 18 | if (!player.has_value()) 19 | { 20 | return error(ERR_INVALID_SESSION); 21 | } 22 | 23 | result["info"]["begin"] = 0; 24 | result["info"]["current"] = 0; 25 | result["info"]["day_battle"] = 0; 26 | result["info"]["end"] = 0; 27 | result["info"]["next"] = 0; 28 | result["info"]["history_count"] = 0; 29 | result["info"]["player_count"] = 0; 30 | result["info"]["point"] = 0; 31 | result["info"]["section"] = 0; 32 | result["info"]["match_history"] = nlohmann::json::array(); 33 | result["info"]["player_count"] = nlohmann::json::array(); 34 | result["result"] = "ERR_NOTIMPLEMENTED"; 35 | 36 | return result; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_league_result.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_league_result : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_login_param.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_login_param.hpp" 4 | 5 | #include "database/models/items.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | cmd_get_login_param::cmd_get_login_param() 12 | { 13 | this->list_ = resource(RESOURCE_LOGIN_PARAM); 14 | } 15 | 16 | nlohmann::json cmd_get_login_param::execute(nlohmann::json& data, const std::optional& player) 17 | { 18 | nlohmann::json result = this->list_; 19 | result["server_product_params"] = database::items::get_static_list_json(); 20 | return result; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_login_param.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_login_param : public command_handler 8 | { 9 | public: 10 | cmd_get_login_param(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_mbcoin_remainder.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_mbcoin_remainder.hpp" 4 | 5 | #include "database/models/player_data.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_get_mbcoin_remainder::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | const auto p_data = database::player_data::find(player->get_id()); 22 | if (!player.has_value()) 23 | { 24 | return error(ERR_INVALIDARG); 25 | } 26 | 27 | result["remainder"] = p_data->get_mb_coin(); 28 | result["result"] = utils::tpp::get_error(NOERR); 29 | 30 | return result; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_mbcoin_remainder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_mbcoin_remainder : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_next_maintenance.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_next_maintenance.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_next_maintenance::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_next_maintenance.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_next_maintenance : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_online_development_progress.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_online_development_progress.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_online_development_progress::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_online_development_progress.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_online_development_progress : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_online_prison_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_online_prison_list.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_online_prison_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | 13 | result["prison_soldier_param"] = nlohmann::json::array(); 14 | result["rescue_list"] = nlohmann::json::array(); 15 | result["rescue_num"] = 0; 16 | result["soldier_num"] = 0; 17 | result["total_num"] = 0; 18 | result["result"] = utils::tpp::get_error(NOERR); 19 | 20 | return result; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_online_prison_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_online_prison_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_own_fob_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_own_fob_list.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_get_own_fob_list::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | result["result"] = "NOERR"; 17 | 18 | if (!player.has_value()) 19 | { 20 | return error(ERR_INVALID_SESSION); 21 | } 22 | 23 | result["fob"] = nlohmann::json::array(); 24 | result["enable_security_challenge"] = player->is_security_challenge_enabled(); 25 | 26 | auto fob_list = database::fobs::get_fob_list(player->get_id()); 27 | auto index = 0; 28 | for (auto& fob : fob_list) 29 | { 30 | auto area_opt = database::fobs::get_area(fob.get_area_id()); 31 | auto& area = area_opt.value(); 32 | result["fob"][index]["area_id"] = fob.get_area_id(); 33 | result["fob"][index]["cluster_param"] = nlohmann::json::array(); 34 | result["fob"][index]["construct_param"] = fob.get_construct_param(); 35 | result["fob"][index]["fob_index"] = index; 36 | result["fob"][index]["mother_base_id"] = fob.get_id(); 37 | result["fob"][index]["platform_count"] = 0; 38 | result["fob"][index]["price"] = area["price"]; 39 | result["fob"][index]["security_rank"] = 0; 40 | 41 | ++index; 42 | } 43 | 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_own_fob_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_own_fob_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_pay_item_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_pay_item_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_pay_item_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_pay_item_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_pay_item_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_pf_detail_params.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_pf_detail_params.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_pf_detail_params::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_pf_detail_params.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_pf_detail_params : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_pf_point_exchange_params.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_pf_point_exchange_params.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_pf_point_exchange_params::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_pf_point_exchange_params.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_pf_point_exchange_params : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_platform_construction_progress.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_platform_construction_progress.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_platform_construction_progress::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_platform_construction_progress.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_platform_construction_progress : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_player_platform_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_player_platform_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_playerlist.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_playerlist : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_previous_short_pfleague_result.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_previous_short_pfleague_result.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_previous_short_pfleague_result::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_previous_short_pfleague_result.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_previous_short_pfleague_result : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_purchasable_area_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_purchasable_area_list.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | cmd_get_purchasable_area_list::cmd_get_purchasable_area_list() 12 | { 13 | this->list_ = database::fobs::get_area_list(); 14 | } 15 | 16 | nlohmann::json cmd_get_purchasable_area_list::execute(nlohmann::json& data, const std::optional& player) 17 | { 18 | return this->list_; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_purchasable_area_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_purchasable_area_list : public command_handler 8 | { 9 | public: 10 | cmd_get_purchasable_area_list(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_purchase_history.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_purchase_history.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_purchase_history::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_purchase_history.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_purchase_history : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_purchase_history_num.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_purchase_history_num.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_purchase_history_num::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_purchase_history_num.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_purchase_history_num : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_ranking.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_ranking : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | bool needs_player() override; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_rental_loadout_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_rental_loadout_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_rental_loadout_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_rental_loadout_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_rental_loadout_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_resource_param.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_resource_param.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_resource_param::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | 13 | result["result"] = "NOERR"; 14 | result["nuclear_develop_costs"][0] = 750000; 15 | result["nuclear_develop_costs"][1] = 50000; 16 | result["nuclear_develop_costs"][2] = 75000; 17 | 18 | return result; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_resource_param.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_resource_param : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_security_info.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_security_info.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_security_info::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | 13 | result["end_date"] = 0; 14 | result["in_contract"] = 0; 15 | result["in_interval"] = 0; 16 | result["interval_end_date"] = 0; 17 | 18 | return result; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_security_info.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_security_info : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_security_product_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_security_product_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_security_product_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_security_product_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_security_product_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_security_setting_param.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_security_setting_param.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | cmd_get_security_setting_param::cmd_get_security_setting_param() 10 | { 11 | this->list_ = resource(RESOURCE_SECURITY_SETTINGS_PARAM); 12 | } 13 | 14 | nlohmann::json cmd_get_security_setting_param::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | return this->list_; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_security_setting_param.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_security_setting_param : public command_handler 8 | { 9 | public: 10 | cmd_get_security_setting_param(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_server_item.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_server_item.hpp" 4 | 5 | #include "database/models/items.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_get_server_item::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | const auto& item_id_j = data["item_id"]; 22 | if (!item_id_j.is_number_integer()) 23 | { 24 | return error(ERR_INVALIDARG); 25 | } 26 | 27 | const auto item_id = item_id_j.get(); 28 | auto item_status = database::items::get_item(player->get_id(), item_id); 29 | 30 | result["item"]["create_date"] = item_status.get_create_time(); 31 | result["item"]["develop"] = item_status.get_develop(); 32 | result["item"]["gmp"] = item_status.get_gmp(); 33 | result["item"]["id"] = item_status.get_id(); 34 | result["item"]["left_second"] = item_status.get_left_second(); 35 | result["item"]["max_second"] = item_status.get_max_second(); 36 | result["item"]["mb_coin"] = utils::tpp::calculate_mb_coins(item_status.get_max_second(), database::vars.cost_factor_item_dev); 37 | result["item"]["open"] = item_status.is_open(); 38 | 39 | result["result"] = "NOERR"; 40 | result["xuid"] = {}; 41 | 42 | return result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_server_item.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_server_item : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_server_item_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_server_item_list.hpp" 4 | 5 | #include "database/models/items.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_get_server_item_list::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | auto status_list = database::items::get_item_list(player->get_id()); 22 | 23 | auto index = 0; 24 | for (const auto& item_status : status_list) 25 | { 26 | const auto i = index++; 27 | 28 | result["item_list"][i]["create_date"] = item_status.second.get_create_time(); 29 | result["item_list"][i]["develop"] = item_status.second.get_develop(); 30 | result["item_list"][i]["gmp"] = item_status.second.get_gmp(); 31 | result["item_list"][i]["id"] = item_status.second.get_id(); 32 | result["item_list"][i]["left_second"] = item_status.second.get_left_second(); 33 | result["item_list"][i]["max_second"] = item_status.second.get_max_second(); 34 | result["item_list"][i]["mb_coin"] = utils::tpp::calculate_mb_coins(item_status.second.get_max_second(), database::vars.cost_factor_item_dev); 35 | result["item_list"][i]["open"] = item_status.second.is_open(); 36 | } 37 | 38 | result["item_num"] = status_list.size(); 39 | result["develop_limit"] = database::vars.item_dev_limit; 40 | 41 | result["result"] = "NOERR"; 42 | result["xuid"] = {}; 43 | 44 | return result; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_server_item_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_server_item_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_shop_item_name_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_shop_item_name_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_shop_item_name_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_shop_item_name_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_shop_item_name_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_short_pfleague_result.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_short_pfleague_result.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_short_pfleague_result::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_short_pfleague_result.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_short_pfleague_result : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_sneak_target_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_sneak_target_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_sneak_target_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_sneak_target_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_sneak_target_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_steam_shop_item_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_steam_shop_item_list.hpp" 4 | 5 | namespace tpp 6 | { 7 | cmd_get_steam_shop_item_list::cmd_get_steam_shop_item_list() 8 | { 9 | this->list_ = resource(RESOURCE_STEAM_SHOP_ITEM_LIST); 10 | } 11 | 12 | nlohmann::json cmd_get_steam_shop_item_list::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | return this->list_; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_steam_shop_item_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_steam_shop_item_list : public command_handler 8 | { 9 | public: 10 | cmd_get_steam_shop_item_list(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_troops_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_troops_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_troops_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_troops_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_troops_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_wormhole_list.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_get_wormhole_list.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_get_wormhole_list::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_get_wormhole_list.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_get_wormhole_list : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_mining_resource.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_mining_resource.hpp" 4 | 5 | #include "database/models/items.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | cmd_mining_resource::cmd_mining_resource() 12 | { 13 | this->list_ = resource(RESOURCE_MINING_RESOURCE); 14 | } 15 | 16 | nlohmann::json cmd_mining_resource::execute(nlohmann::json& data, const std::optional& player) 17 | { 18 | return this->list_; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_mining_resource.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_mining_resource : public command_handler 8 | { 9 | public: 10 | cmd_mining_resource(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | 13 | private: 14 | nlohmann::json list_; 15 | 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_notice_sneak_mother_base.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_notice_sneak_mother_base.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_notice_sneak_mother_base::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_notice_sneak_mother_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_notice_sneak_mother_base : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_open_steam_shop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_open_steam_shop.hpp" 4 | 5 | #include "database/models/player_data.hpp" 6 | 7 | namespace tpp 8 | { 9 | cmd_open_steam_shop::cmd_open_steam_shop() 10 | { 11 | this->list_ = resource(RESOURCE_STEAM_SHOP_ITEM_LIST); 12 | } 13 | 14 | nlohmann::json cmd_open_steam_shop::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | const auto& steam_item_id_j = data["steam_item_id"]; 17 | 18 | nlohmann::json result; 19 | result["orderid"] = 0; 20 | result["transid"] = 0; 21 | result["result"] = utils::tpp::get_error(ERR_INVALIDARG); // intentional error 22 | 23 | if (!steam_item_id_j.is_number_unsigned()) 24 | { 25 | return result; 26 | } 27 | 28 | const auto steam_item_id = steam_item_id_j.get(); 29 | const auto& list = this->list_["list"]; 30 | 31 | if (!list.is_array()) 32 | { 33 | return result; 34 | } 35 | 36 | const auto get_item_index = [&] 37 | { 38 | for (auto i = 0; i < list.size(); i++) 39 | { 40 | if (list[i]["steam_item_id"] == steam_item_id) 41 | { 42 | return i; 43 | } 44 | } 45 | 46 | return -1; 47 | }; 48 | 49 | const auto index = get_item_index(); 50 | if (index == -1) 51 | { 52 | return result; 53 | } 54 | 55 | const auto& mb_coins_j = list[index]["mb_coins"]; 56 | if (!mb_coins_j.is_number_unsigned()) 57 | { 58 | return result; 59 | } 60 | 61 | const auto mb_coins = mb_coins_j.get(); 62 | database::player_data::add_coins(player->get_id(), mb_coins); 63 | 64 | return result; 65 | } 66 | 67 | bool cmd_open_steam_shop::needs_player() 68 | { 69 | return true; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_open_steam_shop.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_open_steam_shop : public command_handler 8 | { 9 | public: 10 | cmd_open_steam_shop(); 11 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 12 | bool needs_player() override; 13 | 14 | private: 15 | nlohmann::json list_; 16 | 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_open_wormhole.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_open_wormhole.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | #include "database/models/wormholes.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_open_wormhole::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | result["result"] = "NOERR"; 16 | 17 | if (!player.has_value()) 18 | { 19 | return error(ERR_INVALID_SESSION); 20 | } 21 | 22 | const auto& player_id_j = data["player_id"]; 23 | const auto& to_player_id_j = data["to_player_id"]; 24 | const auto& retaliate_score_j = data["retaliate_score"]; 25 | const auto& flag_j = data["flag"]; 26 | const auto& is_open_j = data["is_open"]; 27 | 28 | if (!player_id_j.is_number_unsigned() || !to_player_id_j.is_number_unsigned() || 29 | !retaliate_score_j.is_number_unsigned() || !flag_j.is_string() || !is_open_j.is_number_unsigned()) 30 | { 31 | return error(ERR_INVALIDARG); 32 | } 33 | 34 | if (player_id_j != player->get_id()) 35 | { 36 | return error(ERR_INVALIDARG); 37 | } 38 | 39 | const auto to_player_id = to_player_id_j.get(); 40 | const auto retaliate_score = retaliate_score_j.get(); 41 | const auto flag = flag_j.get(); 42 | const auto flag_id = database::wormholes::get_flag_id(flag); 43 | const auto is_open = data["is_open"] == 1; 44 | 45 | if (flag_id == database::wormholes::wormhole_flag_invalid) 46 | { 47 | return error(ERR_INVALIDARG); 48 | } 49 | 50 | database::wormholes::add_wormhole(player->get_id(), to_player_id, flag_id, is_open, retaliate_score); 51 | 52 | return result; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_open_wormhole.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_open_wormhole : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_first_fob.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_first_fob.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_purchase_first_fob::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | result["result"] = "NOERR"; 17 | 18 | if (!player.has_value()) 19 | { 20 | return error(ERR_INVALID_SESSION); 21 | } 22 | 23 | const auto& area_id_j = data["area_id"]; 24 | 25 | const auto fob_list = database::fobs::get_fob_list(player->get_id()); 26 | if (fob_list.size() != 0 || !area_id_j.is_number_integer()) 27 | { 28 | return error(ERR_INVALIDARG); 29 | } 30 | 31 | const auto area_id = area_id_j.get(); 32 | const auto area = database::fobs::get_area(area_id); 33 | if (!area.has_value()) 34 | { 35 | return error(ERR_INVALIDARG); 36 | } 37 | 38 | database::fobs::create(player->get_id(), area_id); 39 | 40 | return result; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_first_fob.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_first_fob : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_fob.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_fob.hpp" 4 | 5 | #include "database/models/fobs.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_purchase_fob::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | result["result"] = "NOERR"; 17 | 18 | if (!player.has_value()) 19 | { 20 | return error(ERR_INVALID_SESSION); 21 | } 22 | 23 | const auto& area_id_j = data["area_id"]; 24 | 25 | const auto p_data = database::player_data::find(player->get_id()); 26 | const auto fob_list = database::fobs::get_fob_list(player->get_id()); 27 | 28 | if (!p_data.get() || fob_list.size() >= 4 || fob_list.size() < 1 || !area_id_j.is_number_integer()) 29 | { 30 | return error(ERR_INVALIDARG); 31 | } 32 | 33 | const auto area_id = area_id_j.get(); 34 | const auto area_opt = database::fobs::get_area(area_id); 35 | if (!area_opt.has_value()) 36 | { 37 | return error(ERR_INVALIDARG); 38 | } 39 | 40 | const auto& area = area_opt.value(); 41 | const auto price = area["price"].get(); 42 | 43 | if (database::player_data::spend_coins(player->get_id(), price)) 44 | { 45 | database::fobs::create(player->get_id(), area_id); 46 | } 47 | else 48 | { 49 | result["result"] = utils::tpp::get_error(ERR_MBCOIN_SHORTAGE); 50 | } 51 | 52 | return result; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_fob.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_fob : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_nuclear_completion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_nuclear_completion.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_purchase_nuclear_completion::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_nuclear_completion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_nuclear_completion : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_online_deployment_completion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_online_deployment_completion.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_purchase_online_deployment_completion::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_online_deployment_completion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_online_deployment_completion : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_online_development_completion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_online_development_completion.hpp" 4 | 5 | #include "database/models/player_data.hpp" 6 | #include "database/models/items.hpp" 7 | 8 | namespace tpp 9 | { 10 | nlohmann::json cmd_purchase_online_development_completion::execute(nlohmann::json& data, const std::optional& player) 11 | { 12 | const auto& develop_id_j = data["develop_id"]; 13 | 14 | if (!develop_id_j.is_number_unsigned()) 15 | { 16 | return error(ERR_INVALIDARG); 17 | } 18 | 19 | const auto item_id = develop_id_j.get(); 20 | 21 | nlohmann::json result; 22 | 23 | const auto item = database::items::get_item(player->get_id(), item_id); 24 | if (item.get_develop() != database::items::indev) 25 | { 26 | return error(ERR_INVALIDARG); 27 | } 28 | 29 | if (database::player_data::spend_coins(player->get_id(), item.get_mb_coin())) 30 | { 31 | if (!database::items::force_develop(player->get_id(), item.get_id())) 32 | { 33 | database::player_data::add_coins(player->get_id(), item.get_mb_coin()); 34 | return error(ERR_DATABASE); 35 | } 36 | } 37 | else 38 | { 39 | return error(ERR_MBCOIN_SHORTAGE); 40 | } 41 | 42 | return error(NOERR); 43 | } 44 | 45 | bool cmd_purchase_online_development_completion::needs_player() 46 | { 47 | return true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_online_development_completion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_online_development_completion : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | bool needs_player() override; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_platform_construction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_platform_construction.hpp" 4 | 5 | #include "database/models/player_data.hpp" 6 | #include "database/models/players.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_purchase_platform_construction::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | const auto& remaining_time_j = data["remaining_time"]; 15 | 16 | if (!remaining_time_j.is_number_unsigned()) 17 | { 18 | return error(ERR_INVALIDARG); 19 | } 20 | 21 | const auto remaining_time = remaining_time_j.get(); 22 | const auto cost = utils::tpp::calculate_mb_coins(remaining_time, database::vars.cost_factor_platform_construction); 23 | if (!database::player_data::spend_coins(player->get_id(), cost)) 24 | { 25 | return error(ERR_MBCOIN_SHORTAGE); 26 | } 27 | 28 | return error(NOERR); 29 | } 30 | 31 | bool cmd_purchase_platform_construction::needs_player() 32 | { 33 | return true; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_platform_construction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_platform_construction : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | bool needs_player() override; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_resources_processing.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_resources_processing.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_purchase_resources_processing::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_resources_processing.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_resources_processing : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_security_service.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_security_service.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_purchase_security_service::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_security_service.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_security_service : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_send_troops_completion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_send_troops_completion.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_purchase_send_troops_completion::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_send_troops_completion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_send_troops_completion : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_wepon_development_completion.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_purchase_wepon_development_completion.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_purchase_wepon_development_completion::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_purchase_wepon_development_completion.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_purchase_wepon_development_completion : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_relocate_fob.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_relocate_fob.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_relocate_fob::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_relocate_fob.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_relocate_fob : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_rental_loadout.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_rental_loadout.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_rental_loadout::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_rental_loadout.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_rental_loadout : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_reqauth_https.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_reqauth_https : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_reqauth_sessionsvr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_reqauth_sessionsvr.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_reqauth_sessionsvr::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_reqauth_sessionsvr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_reqauth_sessionsvr : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_request_relief.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_request_relief.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_request_relief::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_request_relief.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_request_relief : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_reset_mother_base.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_reset_mother_base.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_reset_mother_base::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_reset_mother_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_reset_mother_base : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sale_resource.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | #include "../main_handler.hpp" 5 | 6 | namespace tpp 7 | { 8 | class cmd_sale_resource : public command_handler 9 | { 10 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 11 | }; 12 | } 13 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_boot.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_boot.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_boot::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "NOERR"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_boot.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_boot : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_deploy_injure.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_deploy_injure.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_deploy_injure::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_deploy_injure.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_deploy_injure : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_heartbeat.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_heartbeat.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_heartbeat::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_heartbeat.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_heartbeat : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_ipandport.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_ipandport.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | nlohmann::json cmd_send_ipandport::execute(nlohmann::json& data, const std::optional& player) 12 | { 13 | nlohmann::json result; 14 | result["result"] = "NOERR"; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | const auto& ex_ip_j = data["ex_ip"]; 22 | const auto& in_ip_j = data["in_ip"]; 23 | const auto& ex_port_j = data["ex_port"]; 24 | const auto& in_port_j = data["in_port"]; 25 | const auto& nat_j = data["nat"]; 26 | 27 | if (!ex_ip_j.is_string() || !in_ip_j.is_string() || !nat_j.is_string() || 28 | !ex_port_j.is_number_unsigned() || !in_port_j.is_number_unsigned()) 29 | { 30 | return error(ERR_INVALIDARG); 31 | } 32 | 33 | const auto ex_ip = ex_ip_j.get(); 34 | const auto ex_port = ex_port_j.get(); 35 | const auto in_ip = in_ip_j.get(); 36 | const auto in_port = in_port_j.get(); 37 | const auto nat = nat_j.get(); 38 | 39 | database::players::set_ip_and_port(player->get_id(), 40 | ex_ip, ex_port, in_ip, in_port, nat 41 | ); 42 | 43 | return result; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_ipandport.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_ipandport : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_mission_result.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_mission_result.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_mission_result::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_mission_result.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_mission_result : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_nuclear.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_nuclear.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_nuclear::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_nuclear.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_nuclear : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_online_challenge_task_status.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_online_challenge_task_status.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_online_challenge_task_status::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_online_challenge_task_status.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_online_challenge_task_status : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_sneak_result.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_sneak_result : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_suspicion_play_data.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_suspicion_play_data.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_suspicion_play_data::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_suspicion_play_data.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_suspicion_play_data : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_troops.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_send_troops.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_send_troops::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_send_troops.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_send_troops : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_set_currentplayer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_set_currentplayer.hpp" 4 | 5 | #include "database/auth.hpp" 6 | 7 | #include "database/models/players.hpp" 8 | #include "database/models/player_records.hpp" 9 | 10 | #include 11 | 12 | namespace tpp 13 | { 14 | nlohmann::json cmd_set_currentplayer::execute(nlohmann::json& data, const std::optional& player) 15 | { 16 | nlohmann::json result; 17 | result["xuid"] = {}; 18 | 19 | if (!player.has_value()) 20 | { 21 | return error(ERR_INVALID_SESSION); 22 | } 23 | 24 | result["player_id"] = player->get_id(); 25 | result["result"] = "NOERR"; 26 | 27 | return result; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_set_currentplayer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_set_currentplayer : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_set_security_challenge.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_set_security_challenge.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | #include "database/models/player_records.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_set_security_challenge::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | 16 | if (!player.has_value()) 17 | { 18 | return error(ERR_INVALID_SESSION); 19 | } 20 | 21 | const auto enabled = data["status"] == "ENABLE"; 22 | if (!database::players::set_security_challenge(player->get_id(), enabled)) 23 | { 24 | return error(ERR_DATABASE); 25 | } 26 | 27 | database::player_records::clear_shield_date(player->get_id()); 28 | 29 | return result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_set_security_challenge.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_set_security_challenge : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sneak_mother_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sneak_mother_base : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_spend_server_wallet.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_spend_server_wallet.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_spend_server_wallet::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_spend_server_wallet.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_spend_server_wallet : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_start_consume_transaction.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_start_consume_transaction.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_start_consume_transaction::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_start_consume_transaction.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_start_consume_transaction : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_emblem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_sync_emblem.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | #include "database/models/player_data.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_sync_emblem::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | result["result"] = "NOERR"; 16 | 17 | if (!player.has_value()) 18 | { 19 | return error(ERR_INVALID_SESSION); 20 | } 21 | 22 | if (!data["emblem"].is_object()) 23 | { 24 | return error(ERR_INVALIDARG); 25 | } 26 | 27 | database::player_data::sync_emblem(player->get_id(), data["emblem"]); 28 | 29 | return result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_emblem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sync_emblem : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_loadout.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_sync_loadout.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | #include "database/models/player_data.hpp" 7 | 8 | #include 9 | 10 | namespace tpp 11 | { 12 | nlohmann::json cmd_sync_loadout::execute(nlohmann::json& data, const std::optional& player) 13 | { 14 | nlohmann::json result; 15 | result["result"] = "NOERR"; 16 | 17 | if (!player.has_value()) 18 | { 19 | return error(ERR_INVALID_SESSION); 20 | } 21 | 22 | if (!data["loadout"].is_object()) 23 | { 24 | return error(ERR_INVALIDARG); 25 | } 26 | 27 | database::player_data::sync_loadout(player->get_id(), data["loadout"]); 28 | 29 | return result; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_loadout.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sync_loadout : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_mother_base.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sync_mother_base : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_reset.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_sync_reset.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_sync_reset::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_reset.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sync_reset : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_resource.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sync_resource : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_soldier_bin.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sync_soldier_bin : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_sync_soldier_diff.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_sync_soldier_diff : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_update_session.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_update_session.hpp" 4 | 5 | #include "database/models/players.hpp" 6 | 7 | #include 8 | 9 | namespace tpp 10 | { 11 | nlohmann::json cmd_update_session::execute(nlohmann::json& data, const std::optional& player) 12 | { 13 | nlohmann::json result; 14 | 15 | if (!player.has_value()) 16 | { 17 | return error(ERR_INVALID_SESSION); 18 | } 19 | 20 | if (!database::players::update_session(player.value())) 21 | { 22 | return error(ERR_DATABASE); 23 | } 24 | 25 | const auto active_sneak = database::players::find_active_sneak(player->get_id(), true, true); 26 | auto sneak_mode = active_sneak.has_value() ? 0 : -1; 27 | auto fob_index = active_sneak.has_value() ? 0 : -1; 28 | 29 | result["fob_index"] = sneak_mode; 30 | result["sneak_mode"] = fob_index; 31 | result["result"] = utils::tpp::get_error(NOERR); 32 | 33 | return result; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_update_session.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_update_session : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_use_pf_item.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_use_pf_item.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_use_pf_item::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_use_pf_item.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_use_pf_item : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_use_short_pf_item.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "cmd_use_short_pf_item.hpp" 4 | 5 | // unimplemented 6 | 7 | namespace tpp 8 | { 9 | nlohmann::json cmd_use_short_pf_item::execute(nlohmann::json& data, const std::optional& player) 10 | { 11 | nlohmann::json result; 12 | result["result"] = "ERR_NOTIMPLEMENTED"; 13 | return result; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/commands/cmd_use_short_pf_item.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class cmd_use_short_pf_item : public command_handler 8 | { 9 | nlohmann::json execute(nlohmann::json& data, const std::optional& player) override; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/endpoints/main/main_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/endpoint_handler.hpp" 4 | 5 | #include 6 | 7 | namespace tpp 8 | { 9 | class main_handler : public endpoint_handler 10 | { 11 | public: 12 | main_handler(); 13 | 14 | std::optional decrypt_request(const std::string& data, 15 | std::optional& player) override; 16 | bool verify_request(const nlohmann::json& request) override; 17 | std::optional encrypt_response(const nlohmann::json& request, nlohmann::json data, 18 | const std::optional& player) override; 19 | 20 | private: 21 | utils::cryptography::blowfish blow_; 22 | 23 | }; 24 | } -------------------------------------------------------------------------------- /src/server/platforms/tppstm/tppstm_handler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "endpoints/gate/gate_handler.hpp" 4 | #include "endpoints/main/main_handler.hpp" 5 | 6 | #include "tppstm_handler.hpp" 7 | 8 | namespace tpp 9 | { 10 | tppstm_handler::tppstm_handler() 11 | { 12 | this->register_handler("gate"); 13 | this->register_handler("main"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/server/platforms/tppstm/tppstm_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/platform_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class tppstm_handler : public platform_handler 8 | { 9 | public: 10 | tppstm_handler(); 11 | 12 | private: 13 | 14 | }; 15 | } -------------------------------------------------------------------------------- /src/server/platforms/tppstmweb/endpoints/var_handler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "var_handler.hpp" 4 | 5 | #include "utils/encoding.hpp" 6 | #include "utils/tpp.hpp" 7 | 8 | #include 9 | #include 10 | 11 | namespace tpp 12 | { 13 | var_handler::var_handler(const std::string& name, const std::string& value) 14 | : name_(name) 15 | , value_(value) 16 | { 17 | } 18 | 19 | std::optional var_handler::handle_command(const utils::request_params& params, const std::string& data) 20 | { 21 | if (params.uri == "/tppstmweb/"s + this->name_) 22 | { 23 | return {this->value_}; 24 | } 25 | 26 | return {}; 27 | } 28 | } -------------------------------------------------------------------------------- /src/server/platforms/tppstmweb/endpoints/var_handler.hpp: -------------------------------------------------------------------------------- 1 | #include "types/endpoint_handler.hpp" 2 | 3 | namespace tpp 4 | { 5 | class var_handler : public endpoint_handler 6 | { 7 | public: 8 | var_handler(const std::string& name, const std::string& value); 9 | 10 | std::optional handle_command(const utils::request_params& params, const std::string& data) override; 11 | 12 | private: 13 | std::string name_; 14 | std::string value_; 15 | 16 | }; 17 | } -------------------------------------------------------------------------------- /src/server/platforms/tppstmweb/tppstmweb_handler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "endpoints/var_handler.hpp" 4 | 5 | #include "tppstmweb_handler.hpp" 6 | 7 | namespace tpp 8 | { 9 | tppstmweb_handler::tppstmweb_handler() 10 | { 11 | this->register_handler("coin", "coin/coin.var", "null"); 12 | this->register_handler("eula", "eula/eula.var", "null"); 13 | this->register_handler("gdpr", "gdpr/privacy.var", "null"); 14 | this->register_handler("privacy", "privacy/privacy.var", "null"); 15 | this->register_handler("privacy_jp", "privacy_jp/privacy.var", "null"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/server/platforms/tppstmweb/tppstmweb_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types/platform_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | class tppstmweb_handler : public platform_handler 8 | { 9 | public: 10 | tppstmweb_handler(); 11 | 12 | private: 13 | 14 | }; 15 | } -------------------------------------------------------------------------------- /src/server/resource.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define RESOURCE_DLL_LIBMYSQL 100 4 | #define RESOURCE_DLL_LIBCRYPTO 101 5 | #define RESOURCE_DLL_LIBSSL 102 6 | 7 | #define RESOURCE_GDPR_CHECK 200 8 | #define RESOURCE_CHALLENGE_TASK_REWARDS 201 9 | #define RESOURCE_LOGIN_PARAM 202 10 | #define RESOURCE_INFORMATIONLIST2 203 11 | #define RESOURCE_ITEM_LIST 204 12 | #define RESOURCE_MINING_RESOURCE 205 13 | #define RESOURCE_AREA_LIST 206 14 | #define RESOURCE_FOB_PARAM 207 15 | #define RESOURCE_SECURITY_SETTINGS_PARAM 208 16 | #define RESOURCE_FOB_DEPLOY_LIST 209 17 | #define RESOURCE_STEAM_SHOP_ITEM_LIST 210 18 | -------------------------------------------------------------------------------- /src/server/resources/data/steam_shop_item_list.json: -------------------------------------------------------------------------------- 1 | { 2 | "list": [ 3 | { 4 | "product_name": "100 MB Coins", 5 | "steam_item_id": 1, 6 | "mb_coins": 100 7 | }, 8 | { 9 | "product_name": "550 MB Coins", 10 | "steam_item_id": 2, 11 | "mb_coins": 550 12 | }, 13 | { 14 | "product_name": "1150 MB Coins", 15 | "steam_item_id": 3, 16 | "mb_coins": 1150 17 | }, 18 | { 19 | "product_name": "3500 MB Coins", 20 | "steam_item_id": 4, 21 | "mb_coins": 3500 22 | }, 23 | { 24 | "product_name": "6000 MB Coins", 25 | "steam_item_id": 5, 26 | "mb_coins": 6000 27 | } 28 | ] 29 | } -------------------------------------------------------------------------------- /src/server/scripting/engine.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "database/models/event_rankings.hpp" 4 | #include "database/models/fobs.hpp" 5 | #include "database/models/items.hpp" 6 | #include "database/models/player_data.hpp" 7 | #include "database/models/player_follows.hpp" 8 | #include "database/models/player_records.hpp" 9 | #include "database/models/players.hpp" 10 | #include "database/models/sneak_results.hpp" 11 | #include "database/models/wormholes.hpp" 12 | 13 | #pragma warning(push) 14 | #pragma warning(disable: 4702) 15 | 16 | #define SOL_ALL_SAFETIES_ON 1 17 | #define SOL_PRINT_ERRORS 0 18 | #include 19 | 20 | namespace scripting::engine 21 | { 22 | std::optional execute_command_hook(const std::string& command, nlohmann::json& data, const std::optional& player); 23 | } 24 | -------------------------------------------------------------------------------- /src/server/server.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "loader/component_loader.hpp" 4 | 5 | #include "types/server.hpp" 6 | #include "database/database.hpp" 7 | #include "database/auth.hpp" 8 | 9 | #include "component/console.hpp" 10 | #include "component/command.hpp" 11 | 12 | namespace tpp 13 | { 14 | namespace 15 | { 16 | std::atomic_bool killed; 17 | } 18 | 19 | void stop_server() 20 | { 21 | killed = true; 22 | } 23 | 24 | void start_server() 25 | { 26 | const auto _0 = gsl::finally(&component_loader::pre_destroy); 27 | component_loader::pre_start(); 28 | 29 | std::vector threads; 30 | 31 | try 32 | { 33 | database::initialize(); 34 | } 35 | catch (const std::exception& e) 36 | { 37 | console::error("Failed to initialize database: %s\n", e.what()); 38 | return; 39 | } 40 | 41 | auth::initialize_lists(); 42 | 43 | server s; 44 | if (!s.start()) 45 | { 46 | console::error("Failed to start server\n"); 47 | return; 48 | } 49 | 50 | threads.emplace_back([&] 51 | { 52 | while (!killed) 53 | { 54 | s.run_frame(); 55 | } 56 | }); 57 | 58 | threads.emplace_back([] 59 | { 60 | while (!killed) 61 | { 62 | database::cleanup_connections(); 63 | database::run_tasks(); 64 | std::this_thread::sleep_for(100ms); 65 | } 66 | }); 67 | 68 | component_loader::post_start(); 69 | 70 | while (!killed) 71 | { 72 | command::run_frame(); 73 | std::this_thread::sleep_for(1ms); 74 | } 75 | 76 | for (auto& thread : threads) 77 | { 78 | if (thread.joinable()) 79 | { 80 | thread.join(); 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/server/server.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace tpp 4 | { 5 | void stop_server(); 6 | void start_server(); 7 | } 8 | -------------------------------------------------------------------------------- /src/server/std_include.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" 4 | { 5 | int s_read_arc4random(void*, size_t) 6 | { 7 | return -1; 8 | } 9 | 10 | int s_read_getrandom(void*, size_t) 11 | { 12 | return -1; 13 | } 14 | 15 | int s_read_urandom(void*, size_t) 16 | { 17 | return -1; 18 | } 19 | 20 | int s_read_ltm_rng(void*, size_t) 21 | { 22 | return -1; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/server/types/base_handler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "base_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/server/types/base_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace tpp 4 | { 5 | template 6 | class base_handler 7 | { 8 | public: 9 | template 10 | void register_handler(const std::string& name, Args&&... args) 11 | { 12 | this->print_handler_name(name); 13 | auto handler = std::make_unique(std::forward(args)...); 14 | this->handlers_.insert(std::make_pair(name, std::move(handler))); 15 | } 16 | 17 | virtual void print_handler_name([[ maybe_unused ]] const std::string& name) 18 | { 19 | 20 | } 21 | 22 | protected: 23 | std::unordered_map> handlers_; 24 | }; 25 | } 26 | -------------------------------------------------------------------------------- /src/server/types/command_handler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "command_handler.hpp" 4 | 5 | namespace tpp 6 | { 7 | nlohmann::json error(const std::string& id) 8 | { 9 | nlohmann::json result; 10 | result["result"] = id; 11 | return result; 12 | } 13 | 14 | nlohmann::json error(const std::uint32_t id) 15 | { 16 | nlohmann::json result; 17 | result["result"] = utils::tpp::get_error(id); 18 | return result; 19 | } 20 | 21 | nlohmann::json resource(const std::uint32_t id) 22 | { 23 | auto resource = utils::resources::load_json(id); 24 | resource["result"] = utils::tpp::get_error(NOERR); 25 | return resource; 26 | } 27 | 28 | nlohmann::json player_info(const std::uint64_t player_id, const std::uint64_t account_id) 29 | { 30 | nlohmann::json info; 31 | 32 | info["npid"]["handler"]["data"] = ""; 33 | info["npid"]["handler"]["dummy"] = {0, 0, 0}; 34 | info["npid"]["handler"]["term"] = 0; 35 | info["npid"]["opt"] = {0, 0, 0, 0, 0, 0, 0, 0}; 36 | info["npid"]["reserved"] = {0, 0, 0, 0, 0, 0, 0, 0}; 37 | info["player_id"] = player_id; 38 | info["player_name"] = account_id == 0 ? "NotImplement" : std::format("{}_player01", account_id); 39 | info["ugc"] = 1; 40 | info["xuid"] = account_id; 41 | 42 | return info; 43 | } 44 | 45 | nlohmann::json player_info(const database::players::player& player) 46 | { 47 | return player_info(player.get_id(), player.get_account_id()); 48 | } 49 | 50 | nlohmann::json player_info(const std::optional& player) 51 | { 52 | return player_info(*player); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/server/types/command_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "database/models/players.hpp" 4 | #include "utils/tpp.hpp" 5 | 6 | namespace tpp 7 | { 8 | class command_handler 9 | { 10 | public: 11 | virtual nlohmann::json execute(nlohmann::json& data, const std::optional& player) 12 | { 13 | throw std::runtime_error("unimplemented command"); 14 | }; 15 | 16 | virtual bool needs_player() 17 | { 18 | return false; 19 | } 20 | }; 21 | 22 | nlohmann::json error(const std::string& id); 23 | nlohmann::json error(const std::uint32_t id); 24 | nlohmann::json resource(const std::uint32_t id); 25 | nlohmann::json player_info(const std::uint64_t player_id, const std::uint64_t account_id); 26 | nlohmann::json player_info(const database::players::player& player); 27 | nlohmann::json player_info(const std::optional& player); 28 | } 29 | -------------------------------------------------------------------------------- /src/server/types/endpoint_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "base_handler.hpp" 4 | #include "command_handler.hpp" 5 | #include "utils/http_server.hpp" 6 | 7 | namespace tpp 8 | { 9 | class endpoint_handler : public base_handler 10 | { 11 | public: 12 | virtual std::optional decrypt_request(const std::string& data, std::optional& player) 13 | { 14 | return {}; 15 | } 16 | 17 | virtual bool verify_request(const nlohmann::json& request) 18 | { 19 | return false; 20 | } 21 | 22 | virtual std::optional encrypt_response(const nlohmann::json& request, nlohmann::json data, const std::optional& player) 23 | { 24 | return {}; 25 | } 26 | 27 | virtual std::optional handle_command(const utils::request_params& params, const std::string& data); 28 | 29 | void print_handler_name([[ maybe_unused ]] const std::string& name) override; 30 | }; 31 | } 32 | -------------------------------------------------------------------------------- /src/server/types/platform_handler.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "platform_handler.hpp" 4 | 5 | #include "component/console.hpp" 6 | 7 | namespace tpp 8 | { 9 | std::optional platform_handler::handle_endpoint(const utils::request_params& params, const std::string& endpoint, const std::string& data) 10 | { 11 | const auto handler = this->handlers_.find(endpoint); 12 | if (handler == this->handlers_.end()) 13 | { 14 | return {}; 15 | } 16 | 17 | try 18 | { 19 | return handler->second->handle_command(params, data); 20 | } 21 | catch (const std::exception& e) 22 | { 23 | console::error("Error handling command: %s\n", e.what()); 24 | return {}; 25 | } 26 | } 27 | 28 | void platform_handler::print_handler_name([[ maybe_unused ]] const std::string& name) 29 | { 30 | console::log("Registering endpoint \"%s\"\n", name.data()); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/server/types/platform_handler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "base_handler.hpp" 4 | #include "endpoint_handler.hpp" 5 | 6 | namespace tpp 7 | { 8 | class platform_handler : public base_handler 9 | { 10 | public: 11 | std::optional handle_endpoint(const utils::request_params& params, const std::string& endpoint, const std::string& body); 12 | 13 | void print_handler_name([[ maybe_unused ]] const std::string& name) override; 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /src/server/types/server.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "base_handler.hpp" 4 | #include "command_handler.hpp" 5 | #include "endpoint_handler.hpp" 6 | #include "platform_handler.hpp" 7 | 8 | #include "utils/http_server.hpp" 9 | 10 | #include 11 | 12 | namespace tpp 13 | { 14 | class server; 15 | 16 | struct response 17 | { 18 | std::string headers; 19 | std::string body; 20 | }; 21 | 22 | using response_task = std::future>; 23 | 24 | class server : public base_handler 25 | { 26 | public: 27 | server(); 28 | 29 | bool start(); 30 | void run_frame(); 31 | 32 | void request_handler(const utils::http_connection& conn, const utils::request_params& params); 33 | 34 | utils::response_params handle_request(const utils::request_params& params, const std::string& platform, 35 | const std::string& endpoint, const std::string& body); 36 | 37 | private: 38 | std::atomic_bool killed_ = false; 39 | utils::http_server http_server; 40 | 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /src/server/utils/encoding.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "encoding.hpp" 4 | 5 | #include 6 | 7 | namespace utils::encoding 8 | { 9 | std::string split_into_lines(const std::string& string, const size_t chars_per_line) 10 | { 11 | std::string encoded; 12 | 13 | for (size_t i = 0; i < string.size(); i++) 14 | { 15 | encoded += string[i]; 16 | if (((i + 1) % chars_per_line) == 0) 17 | { 18 | encoded.append("\r\n"); 19 | } 20 | } 21 | 22 | encoded.append("\r\n"); 23 | 24 | return encoded; 25 | } 26 | 27 | std::string unescape_json(const std::string& str) 28 | { 29 | auto result = utils::string::replace(str, "\\\\r\\\\n", ""); 30 | result = utils::string::replace(result, "\\r\\n", ""); 31 | result = utils::string::replace(result, "\\", ""); 32 | result = utils::string::replace(result, "\"{", "{"); 33 | result = utils::string::replace(result, "}\"", "}"); 34 | return result; 35 | } 36 | 37 | std::string decode_url_string(const std::string& str) 38 | { 39 | auto result = utils::string::replace(str, "%2B", "+"); 40 | result = utils::string::replace(result, "\r\n", ""); 41 | return result; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/server/utils/encoding.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace utils::encoding 4 | { 5 | std::string split_into_lines(const std::string& string, const size_t chars_per_line = 76); 6 | std::string unescape_json(const std::string& str); 7 | std::string decode_url_string(const std::string& str); 8 | } 9 | -------------------------------------------------------------------------------- /src/server/utils/resources.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "resources.hpp" 4 | 5 | #include 6 | #include 7 | 8 | namespace utils::resources 9 | { 10 | namespace 11 | { 12 | std::unordered_map resource_map = 13 | { 14 | {RESOURCE_GDPR_CHECK, "resources/data/gdpr_check.json"}, 15 | {RESOURCE_CHALLENGE_TASK_REWARDS, "resources/data/challenge_task_rewards.json"}, 16 | {RESOURCE_LOGIN_PARAM, "resources/data/login_param.json"}, 17 | {RESOURCE_INFORMATIONLIST2, "resources/data/informationlist2.json"}, 18 | {RESOURCE_ITEM_LIST, "resources/data/item_list.json"}, 19 | {RESOURCE_MINING_RESOURCE, "resources/data/mining_resource.json"}, 20 | {RESOURCE_AREA_LIST, "resources/data/area_list.json"}, 21 | {RESOURCE_FOB_PARAM, "resources/data/fob_param.json"}, 22 | {RESOURCE_SECURITY_SETTINGS_PARAM, "resources/data/security_setting_param.json"}, 23 | {RESOURCE_FOB_DEPLOY_LIST, "resources/data/fob_deploy_list.json"}, 24 | {RESOURCE_STEAM_SHOP_ITEM_LIST, "resources/data/steam_shop_item_list.json"}, 25 | }; 26 | } 27 | 28 | std::string load(const std::int32_t resource_id) 29 | { 30 | const auto resource_iter = resource_map.find(resource_id); 31 | if (resource_iter == resource_map.end()) 32 | { 33 | return {}; 34 | } 35 | 36 | { 37 | std::string data; 38 | if (utils::io::read_file(resource_iter->second, &data)) 39 | { 40 | return data; 41 | } 42 | } 43 | 44 | return utils::nt::load_resource(resource_id); 45 | } 46 | 47 | nlohmann::json load_json(const std::int32_t resource_id) 48 | { 49 | return nlohmann::json::parse(load(resource_id)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/server/utils/resources.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace utils::resources 4 | { 5 | std::string load(const std::int32_t resource_id); 6 | nlohmann::json load_json(const std::int32_t resource_id); 7 | } 8 | -------------------------------------------------------------------------------- /src/server/utils/tpp_client.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace utils::tpp 11 | { 12 | class tpp_client 13 | { 14 | public: 15 | tpp_client(); 16 | ~tpp_client(); 17 | 18 | void set_url(const std::string& url); 19 | std::string get_url(); 20 | 21 | std::string decrypt_response(const std::string& data, bool use_static = true); 22 | std::optional send_data(const std::string& endpoint, const std::string& data); 23 | std::optional send_command(const std::string& endpoint, 24 | const nlohmann::json& data_params, bool use_crypto = true, const nlohmann::json& params = {}); 25 | 26 | private: 27 | std::string url_; 28 | 29 | utils::cryptography::blowfish static_blow_; 30 | utils::cryptography::blowfish session_blow_; 31 | 32 | }; 33 | } 34 | -------------------------------------------------------------------------------- /tools/premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alicealys/tpp-server-emulator/f6fd41f399727e04d753dc33eb638c824f580c43/tools/premake5.exe --------------------------------------------------------------------------------