Merge branch 'master' into 64-bit-types

This commit is contained in:
Cekis
2022-09-22 11:49:30 -07:00
committed by GitHub
10 changed files with 82 additions and 17 deletions
@@ -3325,7 +3325,7 @@ void CentralServer::handleRequestSceneTransfer(const RequestSceneTransfer &msg)
}
else
{
DEBUG_REPORT_LOG(true, ("Starting planet server for login"));
DEBUG_REPORT_LOG(true, ("Starting planet server for login. Host '%s', Scene: '%s'", getHostForScene(msg.getSceneName()), msg.getSceneName()));
startPlanetServer(getHostForScene(msg.getSceneName()), msg.getSceneName(), 0);
m_messagesWaitingForPlanetServer.push_back(Archive::ByteStream());
msg.pack(m_messagesWaitingForPlanetServer.back());
@@ -5762,8 +5762,7 @@ static void commandFuncCreatePrototype(const Command&, const NetworkId& actor, c
GameControllerMessageFlags::RELIABLE |
GameControllerMessageFlags::DEST_AUTH_CLIENT);
if (!result)
player->stopCrafting(false);
player->stopCrafting(result);
}
// ----------------------------------------------------------------------
@@ -5794,8 +5793,7 @@ static void commandFuncCreateManfSchematic(const Command&, const NetworkId& acto
GameControllerMessageFlags::RELIABLE |
GameControllerMessageFlags::DEST_AUTH_CLIENT);
if (!result)
player->stopCrafting(false);
player->stopCrafting(result);
}
// ----------------------------------------------------------------------
@@ -491,6 +491,8 @@ void ConfigServerGame::install(void)
KEY_STRING (serverLoadLevel, "heavy");
KEY_INT (maxHousingLots, 10);
if (data->baseDecayRate <= 1.0f)
data->baseDecayRate = 1.0f;
@@ -575,6 +575,8 @@ class ConfigServerGame
bool useOldSuidGenerator;
const char * serverLoadLevel;
int maxHousingLots;
};
private:
@@ -1061,6 +1063,8 @@ class ConfigServerGame
static bool getUseOldSuidGenerator();
static const char * getServerLoadLevel();
static int getMaxHousingLots();
};
//-----------------------------------------------------------------------
@@ -3702,4 +3706,11 @@ inline const char *ConfigServerGame::getServerLoadLevel()
return data->serverLoadLevel;
}
//-----------------------------------------------------------------------
inline int ConfigServerGame::getMaxHousingLots(void)
{
return data->maxHousingLots;
}
#endif
@@ -193,9 +193,6 @@ const SharedObjectTemplate * CreatureObject::m_defaultSharedTemplate = nullptr;
//----------------------------------------------------------------------
// The max number of lots available to a player. This value is also defined in base_class.java
static const int HOUSING_MAX_LOTS = 10;
// Slot names
static const ConstCharCrcLowerString DATAPAD_SLOT_NAME("datapad");
@@ -869,6 +866,8 @@ CreatureObject::CreatureObject(const ServerCreatureObjectTemplate* newTemplate)
IGNORE_RETURN(g_creatureList.insert(this));
ObjectTracker::addCreature();
m_maxHousingLots = ConfigServerGame::getMaxHousingLots();
}
//-----------------------------------------------------------------------
@@ -11915,7 +11914,7 @@ void CreatureObject::runMissionCreationQueue()
int CreatureObject::getMaxNumberOfLots() const
{
return HOUSING_MAX_LOTS;
return m_maxHousingLots;
}
//----------------------------------------------------------------------
@@ -1013,6 +1013,9 @@ private:
Archive::AutoDeltaVector<WearableEntry> m_wearableAppearanceData; // Vector for our appearance items.
Archive::AutoDeltaVariable<NetworkId> m_decoyOrigin; // The OID of the player whom we copied for this decoy creature.
// The max number of lots available to a player. This value is also defined in base_class.java
int m_maxHousingLots;
};
//----------------------------------------------------------------------
@@ -1415,6 +1415,36 @@ bool ServerObject::canTrade() const
{
return false;
}
// aconite 3/21/22
// if an item has the move flag MF_GM but *doesn't* have the MF_Player flag
// that object shouldn't be considered tradeable because it isn't intended to
// be moved by a player (fixes, e.g., trading your buyback container)
bool hasGmFlag = false;
bool hasPlayerFlag = false;
auto tpf = dynamic_cast<const ServerObjectTemplate*>(getObjectTemplate());
if(tpf)
{
const size_t flags = tpf->getMoveFlagsCount();
if(flags > 0)
{
for (size_t i = 0; i < flags; i++)
{
if(!hasGmFlag && tpf->getMoveFlags(i) == ServerObjectTemplate::MF_gm)
{
hasGmFlag = true;
}
if (!hasPlayerFlag && tpf->getMoveFlags(i) == ServerObjectTemplate::MF_player)
{
hasPlayerFlag = true;
}
}
if(hasGmFlag && !hasPlayerFlag)
{
return false;
}
}
}
return !markedNoTrade();
}
@@ -116,13 +116,11 @@ SpaceSquad::~SpaceSquad()
}
// Tell all the squads guarding me that I am not longer guardable
SpaceSquadList::iterator iterGuardedByList = m_guardedByList->begin();
for (; iterGuardedByList != m_guardedByList->end(); ++iterGuardedByList)
{
(*iterGuardedByList)->removeGuardTarget();
}
for (SpaceSquadList::iterator it = m_guardedByList->begin(), next_it = it; it != m_guardedByList->end(); it = next_it)
{
++next_it;
(*it)->removeGuardTarget();
}
delete m_guardedByList;
@@ -55,6 +55,7 @@ namespace ScriptMethodsPlayerAccountNamespace
jboolean JNICALL isIgnoring(JNIEnv *env, jobject self, jlong player, jstring who);
jboolean JNICALL adjustLotCount(JNIEnv *env, jobject self, jlong player, jint adjustment);
jint JNICALL getAccountNumLots(JNIEnv *env, jobject self, jlong player);
jint JNICALL getMaxHousingLots(JNIEnv *env, jobject self);
jint JNICALL getGameFeatureBits(JNIEnv *env, jobject self, jlong player);
jint JNICALL getSubscriptionFeatureBits(JNIEnv *env, jobject self, jlong player);
jboolean JNICALL isUsingAdminLogin(JNIEnv *env, jobject self, jlong player);
@@ -91,6 +92,7 @@ const JNINativeMethod NATIVES[] = {
JF("_isIgnoring", "(JLjava/lang/String;)Z", isIgnoring),
JF("_adjustLotCount", "(JI)Z", adjustLotCount),
JF("_getAccountNumLots", "(J)I", getAccountNumLots),
JF("_getMaxHousingLots", "()I", getMaxHousingLots),
JF("_getGameFeatureBits", "(J)I", getGameFeatureBits),
JF("_getSubscriptionFeatureBits", "(J)I", getSubscriptionFeatureBits),
JF("_isUsingAdminLogin", "(J)Z", isUsingAdminLogin),
@@ -199,6 +201,15 @@ jint JNICALL ScriptMethodsPlayerAccountNamespace::getAccountNumLots(JNIEnv *env,
// ----------------------------------------------------------------------
jint JNICALL ScriptMethodsPlayerAccountNamespace::getMaxHousingLots(JNIEnv *env, jobject self)
{
UNREF(env);
UNREF(self);
return ConfigServerGame::getMaxHousingLots();
}
// ----------------------------------------------------------------------
jint JNICALL ScriptMethodsPlayerAccountNamespace::getGameFeatureBits(JNIEnv *env, jobject self, jlong player)
{
CreatureObject *playerObject = 0;
@@ -77,7 +77,20 @@ int AdminAccountManager::getAdminLevel(const std::string & account)
std::ostringstream postBuffer;
postBuffer << "user_name=" << account << "&secretKey=" << ConfigServerUtility::getExternalAdminLevelsSecretKey();
std::string response = webAPI::simplePost(ConfigServerUtility::getExternalAdminLevelsURL(), std::string(postBuffer.str()), "");
level = std::stoi(response);
// aconite 4/3/22
// stoi inconsistently throws an invalid argument exception from this request
// which causes the login and/or game server to crash on an auth or /setGod;
// this is a temporary patch to safeguard against that until this can be further evaluated
try
{
int newLevel = std::stoi(response);
if(newLevel != 0)
{
level = newLevel;
}
}
catch(std::invalid_argument const& ex) {}
catch(std::out_of_range const& ex) {}
return level;
}