id Tech Forums

id Tech 4 (Doom3/Prey/Q4) => id Tech 4 Mod Coding => Topic started by: VGames on April 02, 2016, 02:13:15 AM

Title: ROE compiling error
Post by: VGames on April 02, 2016, 02:13:15 AM
Ok I'm trying to compile the ROE source and I'm getting an error that has to do with conflicting event types. In Doom 3 it works fine but ROE needs the event to be a different type.

Here's the error:
Code: [Select]
3>AFEntity.cpp
3>.\d3xp\AFEntity.cpp(3539) : error C2440: 'initializing' : cannot convert from 'int' to 'idStr'
3>        Constructor for class 'idStr' is declared 'explicit'

It's referring to this section of code that has to do with harvesting souls with the Bloodstone:
Code: [Select]
if(requiredWeapons.Length() > 0) {
idStr playerWeap = thePlayer->GetCurrentWeapon();
if(playerWeap.Length() == 0 || requiredWeapons.Find(playerWeap, false) == -1) {
okToGive = false;
}
}

It needs the GetCurrentWeapon event to be an idStr type but I have it set up like this in Player.h for many different reasons:
Code: [Select]
int GetCurrentWeapon( void ) { return currentWeapon; };

Here's what it was originally set up as in the ROE source:
Code: [Select]
idStr GetCurrentWeapon();

Any ideas how to work around this? Commenting this section of code in AFEntity.cpp allows a full compile but in game crashes will occur if a harvet body is nearby and your not using the Bloodstone. You get an error that says function "Charge" is not in the script of whatever weapon you're currently using that's not the Bloodstone.
Title: Re: ROE compiling error
Post by: Phrozo on April 02, 2016, 03:31:02 AM
Why did you change the return type from idStr to int? You either are going to have to revert back to idStr or refactor all code that calls GetCurrentWeapon()
Title: Re: ROE compiling error
Post by: VGames on April 02, 2016, 11:55:18 AM
Sikkmod did this for version 1.2. Since Sikkpin never made a version 1.2 for ROE he never addressed this issue. But I fixed it. I changed the bit of code in AFEntity.cpp to this:

Code: [Select]
if(requiredWeapons.Length() > 0) {
int playerWeap = thePlayer->GetCurrentWeapon();
if(playerWeap != 12) {
okToGive = false;
}
}

Worked like a charm. I had the same bad thoughts you had running through my head but then I figured out a much simpler method. Hope this helps somebody.