// This file is part of c-evo-evo. // // This software is governed by the CeCILL license under French law and // abiding by the rules of distribution of free software. You can use, // modify and/or redistribute the software under the terms of the CeCILL // license as circulated by CEA, CNRS and INRIA at the following URL // "http://www.cecill.info". // // As a counterpart to the access to the source code and rights to copy, // modify and redistribute granted by the license, users are provided only // with a limited warranty and the software's author, the holder of the // economic rights, and the successive licensors have only limited // liability. // // In this respect, the user's attention is drawn to the risks associated // with loading, using, modifying and/or developing or reproducing the // software by the user in light of its specific status of free software, // that may mean that it is complicated to manipulate, and that also // therefore means that it is reserved for developers and experienced // professionals having in-depth computer knowledge. Users are therefore // encouraged to load and test the software's suitability as regards their // requirements in conditions enabling the security of their systems and/or // data to be ensured and, more generally, to use and operate it in the // same conditions as regards security. // // The fact that you are presently reading this means that you have had // knowledge of the CeCILL license and that you accept its terms. #pragma once #include "Cevo/Protocol.h" #include #include #include namespace Cevo { namespace ClientTools { constexpr int nOfferedResourceWeights = 6; constexpr std::uint32_t OfferedResourceWeights[nOfferedResourceWeights] = { rwOff, rwMaxScience, rwForceScience, rwMaxGrowth, rwForceProd, rwMaxProd, }; using TImpOrder = std::array; using TEnhancementJobs = std::uint8_t[12][8]; // Pascal's `set of 0..39`; bit i set means "treat Server() result code i as // success too" (used only for the small 0..39 sub-codes a failed job-start // call can return, never for the >=rExecuted big result codes). using JobResultSet = std::uint64_t; // Module-level state (Pascal's unit-level `var` section). `server`/`g` are // set up once by whatever (not yet ported) code starts a local-player game; // itsMeAgain() then refreshes me/myRO/myMap/myUn/myCity/myModel from `g`. extern TServerCall server; extern TNewGameData g; extern int me; extern TPlayerContext *myRO; extern std::uint32_t *myMap; // ro->Map, indexable as myMap[loc] extern TUn *myUn; // ro->Un, indexable as myUn[uix] extern TCity *myCity; // ro->City, indexable as myCity[cix] extern TModel *myModel; // ro->Model, indexable as myModel[mix] extern std::array advValue; // Computes advValue[] from the Advance prerequisite graph (Pascal's // `initialization` section); call once at startup. void init(); int dLoc(int loc, int dx, int dy); int distance(int loc0, int loc1); bool unrestAtLoc(int uix, int loc); int getMoveAdvice(int uix, int toLoc, TMoveAdviceData &moveAdviceData); int colorOfHealth(int health); bool isMultiPlayerGame(); void itsMeAgain(int p); int getAge(int p); bool isCivilReportNew(int enemy); bool isMilReportNew(int enemy); int cutCityFoodSurplus(int foodSurplus, bool isCityAlive, int gov, int size); int cityTaxBalance(int cix, const TCityReportNew &cityReport); void sumCities(int &taxSum, int &scienceSum); bool jobTest(int uix, int job, JobResultSet ignoreResults = 0); void getUnitInfo(int loc, int &uix, TUnitInfo &unitInfo); void getCityInfo(int loc, int &cix, TCityInfo &cityInfo); bool unitExhausted(int uix); int modelHash(const TModelInfo &modelInfo); int processEnhancement(int uix, const TEnhancementJobs &jobs); bool autoBuild(int cix, const TImpOrder &impOrder); void debugMessage(int level, const QString &text); void cityOptimizer_BeginOfTurn(); void cityOptimizer_CityChange(int cix); void cityOptimizer_TileBecomesAvailable(int loc); void cityOptimizer_ReleaseCityTiles(int cix, int releasedTiles); void cityOptimizer_BeforeRemoveUnit(int uix); void cityOptimizer_AfterRemoveUnit(); void cityOptimizer_EndOfTurn(); TCity *getMyCityByLoc(int loc); TCityInfo *getEnemyCityByLoc(int loc); TUn *getMyUnitByLoc(int loc); TUnitInfo *getEnemyUnitByLoc(int loc); } // namespace ClientTools } // namespace Cevo