PropHunt icon indicating copy to clipboard operation
PropHunt copied to clipboard

Unable to compile prophunt.sp

Open philo23 opened this issue 1 year ago • 3 comments

It seems like currently trying to compile this plugin fails with a few errors, I'm not sure if I'm just doing something silly but everything should be up to date as far as I know.

I'm just trying to compile a version with the hunter freeze fixes because it doesn't appear to be available from the releases yet.

$ ./compile.sh prophunt.sp

Compiling prophunt.sp...
SourcePawn Compiler 1.11.0.6968
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2021 AlliedModders LLC

prophunt/events.sp(98) : error 100: function prototypes do not match
prophunt/convars.sp(226) : error 100: function prototypes do not match
prophunt.sp(455) : error 180: function return type differs from prototype. expected 'int', but got 'void'
prophunt.sp(512) : error 100: function prototypes do not match
prophunt.sp(515) : error 100: function prototypes do not match

5 Errors.

I think the errors seem to be complaining about the return type of some of the timer functions used? but I'm only slightly familiar with SourcePawn so I don't know if it's actually because of some missing dependency or version miss-match or something.

Let me know if you need any more details.

philo23 avatar Sep 01 '24 17:09 philo23

At some point I changed the plugin to use SM 1.12 features and didn't update the README. 1.12 removed the need for timer callbacks to always return an Action. You can fix this by changing the return type for affected callbacks back to Action and returning Plugin_Continue at the end of the function.

Mikusch avatar Sep 01 '24 18:09 Mikusch

Thanks, that looks like it's solved the issue with the timers, I've swapped out the return type for the TF2Items_OnGiveNamedItem_Post any idea if I need to actually return anything from it though?

Long term I'll have a look at updating things to 1.12 but even without any new returns, things seem to be working as expected from a quick test.

philo23 avatar Sep 01 '24 18:09 philo23

At some point I changed the plugin to use SM 1.12 features and didn't update the README. 1.12 removed the need for timer callbacks to always return an Action. You can fix this by changing the return type for affected callbacks back to Action and returning Plugin_Continue at the end of the function.

You could add preprocessor checks for SOURCEMOD_V_MINOR (and probably SOURCEMOD_V_MAJOR to properly handle SourceMod 1.+) to support both SM 1.11 and 1.12 syntax.

#if (SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR >= 12) || SOURCEMOD_V_MAJOR >= 2
static void
#else
static Action
#endif
Timer_PropPostSpawn(Handle timer, int serial)
{
	int client = GetClientFromSerial(serial);
	if (client != 0)
	{
		// Enable thirdperson
		SetVariantInt(PHPlayer(client).InForcedTauntCam);
		AcceptEntityInput(client, "SetForcedTauntCam");
		
		// Apply gameplay conditions
		TF2_AddCondition(client, TFCond_SpawnOutline);
		
		if (ph_prop_afterburn_immune.BoolValue)
			TF2_AddCondition(client, TFCond_AfterburnImmune);
	}
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR < 12
        return Plugin_Continue;
#endif
}

MAGNAT2645 avatar Sep 02 '24 20:09 MAGNAT2645