• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[C++] Adding a variable to player.h causes servercrash

emension

New Member
Joined
Aug 25, 2008
Messages
4
Reaction score
0
Hello,

In TFS 0.2.x i hadnt problem with it, i could just add a variable in player.h

Code:
int32_t team;

then just use it without problems in the player.cpp functions.
Just like this below:

Code:
soulMax = 100;
capacity = 400.00;
team = 0;

Now when i try to add a variable in newest tfs 0.3.6~ the server crashes as soon as the player tries to login in.

I think its something with the memory, therefore could someone tell me the correct way how to fix it?

Regards,
 
I'm almost absolutely sure that i did everything allright.

Here are the snippets of the code from player.cpp and player.h

player.h :
Code:
          private:
		bool talkState[13];
		bool inventoryAbilities[11];
		bool pzLocked;
		bool saving;
		bool isConnecting;
		bool requestedOutfit;
		bool outfitAttributes;
		bool addAttackSkillPoint;

		OperatingSystem_t operatingSystem;
		AccountManager_t accountManager;
		PlayerSex_t managerSex;
		BlockType_t lastAttackBlockType;
		chaseMode_t chaseMode;
		fightMode_t fightMode;
		secureMode_t secureMode;
		tradestate_t tradeState;
		GuildLevel_t guildLevel;
		
       
		int16_t blessings;
		uint16_t maxWriteLen;
		uint16_t sex;
                [B]int32_t Hey;[/B]

etc.
player.cpp

Code:
Player::Player(const std::string& _name, ProtocolGame* p):
	Creature(), transferContainer(ITEM_LOCKER), name(_name), nameDescription(_name), client(p)
{
	if(client)
		client->setPlayer(this);

	pzLocked = isConnecting = addAttackSkillPoint = requestedOutfit = false;
	saving = true;

	lastAttackBlockType = BLOCK_NONE;
	chaseMode = CHASEMODE_STANDSTILL;
	fightMode = FIGHTMODE_ATTACK;
	tradeState = TRADE_NONE;
	accountManager = MANAGER_NONE;
	guildLevel = GUILDLEVEL_NONE;

	promotionLevel = walkTaskEvent = actionTaskEvent = nextStepEvent = bloodHitCount = shieldBlockCount = 0;
	lastAttack = idleTime = marriage = blessings = balance = premiumDays = mana = manaMax = manaSpent = 0;
	soul = guildId = levelPercent = magLevelPercent = magLevel = experience = damageImmunities = 0;
	conditionImmunities = conditionSuppressions = groupId = vocation_id = managerNumber2 = town = skullEnd = 0;
	lastLogin = lastLogout = lastIP = messageTicks = messageBuffer = nextAction = 0;
	editListId = maxWriteLen = windowTextId = rankId = 0;

	purchaseCallback = saleCallback = -1;
	level = shootRange = 1;
	rates[SKILL__MAGLEVEL] = rates[SKILL__LEVEL] = 1.0f;
	soulMax = 100;
	capacity = 400.00;
	
	stamina = STAMINA_MAX;
	lastLoad = lastPing = lastPong = OTSYS_TIME();

	writeItem = NULL;
	group = NULL;
	editHouse = NULL;
	shopOwner = NULL;
	tradeItem = NULL;
	tradePartner = NULL;
	walkTask = NULL;
	[B]Hey = 0;[/B]
	setVocation(0);
	setParty(NULL);


	transferContainer.setParent(NULL);
	for(int32_t i = 0; i < 11; i++)
	{
		inventory[i] = NULL;
		inventoryAbilities[i] = false;
	}

	for(int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
	{
		skills[i][SKILL_LEVEL] = 10;
		skills[i][SKILL_TRIES] = skills[i][SKILL_PERCENT] = 0;
		rates[i] = 1.0f;
	}

	for(int32_t i = SKILL_FIRST; i <= SKILL_LAST; ++i)
		varSkills[i] = 0;

	for(int32_t i = STAT_FIRST; i <= STAT_LAST; ++i)
		varStats[i] = 0;

	for(int32_t i = LOSS_FIRST; i <= LOSS_LAST; ++i)
		lossPercent[i] = 100;

	for(int8_t i = 0; i <= 13; i++)
		talkState[i] = false;
#ifdef __ENABLE_SERVER_DIAGNOSTIC__

	playerCount++;
#endif
}

Server crashes as soon as the player tries to login, so i guess just when the variable is being setted to 0.
I'm trying to compile it using dev cpp++ released on this forum, on win 7 with project settings loaded from dev-cpp folder.
 
Last edited:
Try to delete this variable and rebuild project. Maybe there isn't a problem with a variable, but whole server.

@Pitufo
Yea, that's true.
 
Last edited:
You have to rebuild the project, since when you build only the .cpp are being actually build, so yea as pitufo said you just need to click rebuild all.
 
Back
Top