Effective ACS IWAD Detection

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Effective ACS IWAD Detection

Post by GleasSpty »

I just finished today adding support for all the IWADS recognized by ZDoom to my weapon wheel . . . mostly.

I still have a couple small issues with Freedoom and Harmony. The trick/hack I used to figure out what game/mod one is playing, so I know which weapon_list to load, is I check whether the player has in their inventory whatever the default 'melee' weapon is. For example, I use

Code: Select all

is_heretic = CheckInventory("Staff");
to check if one is playing Heretic,

Code: Select all

is_trailblazer = CheckInventory("Macheterang")
to check if one is playing Trailblazer (a mod by Pillowblaster/DoomNukem, not an IWAD), etc.. This works pretty well, but it has the obvious problem that, if two player classes happen to have the same melee weapon, this trick won't be able to distinguish the two. And that's exactly what happens for Freedoom and Harmony: it seems as if the weapon names for both of these IWADs are exactly the same as those in vanilla Doom.

On one hand, this makes my life easy, because I get functional compatibility with no extra work on my part. The problem, however, is that the sprites on the wheel don't match up with the weapons in the game. I would need to tell the wheel 'engine' to change the sprites, but I can't do that if I can't tell whether the player is playing Doom vs Freedoom vs Harmony.

The best solution would be if there were a way to detect which IWAD a player was playing with ACS. However, it seems as if such a feature was denied previously. Perhaps there is a way to get around this? That is, is there a less straightforward way I could tell whether the player is playing vanilla Doom vs Freedoom vs Harmony? Perhaps Doom vs Freedom would be difficult, but I would imagine there would be at least something different between Doom and Harmony that I would be able to tell. For example, any item a player would have in their inventory in Harmony but not Doom (or vice versa) is enough to do the trick.

Any ideas?
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: Effective ACS IWAD Detection

Post by The Zombie Killer »

You can use my ACS-X library
Alternatively, rip out the game detection related stuff from it
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Effective ACS IWAD Detection

Post by GleasSpty »

You. Are. Awesome. It seems like this is exactly what I need.

I was going through the source, however, and two questions (unrelated to the original) came up. Just to help my understanding: (i) what does "#program define raw on" do?, and (ii) where is the source for libc.bin? (I will almost certainly have more questions as I continue reading the code, but I will try to keep the pestering to a minimum . . .)
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Effective ACS IWAD Detection

Post by GleasSpty »

So it seems as if the basic idea of the game detection, at least as far as the ACS is concerned, is to just check the name of a certain string coming from the LANGUAGE file. What I don't see/understand is how ZDoom knows which LANGUAGE file to load (in the "filters" folder)?
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Effective ACS IWAD Detection

Post by GleasSpty »

Ah, I didn't previously know that lump filtering was a thing. That explains a lot . . .
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Effective ACS IWAD Detection

Post by GleasSpty »

FWIW, I wound up using and adding a new function to the library, int GetDoomVersion(void). There are four possibly return ids: DOOMVERSION_UNKNOWN, DOOMVERSION_DOOM1, DOOMVERSION_DOOM2, and DOOMVERSION_FREEDOOM (0, 1, 2, and 3 respectively). Not sure if this will ever be useful to you, but I've attached the updated library on the off chance it will be (though the .bin files are not updated, just the source).

Certainly I would have had no idea how to do this without your source to look at, so thanks for that!
Attachments
ACS-X.7z
(9.02 KiB) Downloaded 50 times
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: Effective ACS IWAD Detection

Post by The Zombie Killer »

the .bin files are compiled from C code with gdcc-cc, the source for them isn't included yet since they're quite messy due to the current requirements for externalizing C functions to ACS. I'm happy to give that code out on request though.
As for the function, I'll take a look at it and see if it would be useful to add, thanks!

Sorry for the late response by the way, I've had exams all week and somehow managed to pass out at my desk from fatigue

EDIT: To answer the questions in the above posts

"#pragma define raw on" tells gdcc-acc to use C-styled #define macros
libc.bin can be compiled by using the following commands:

Code: Select all

gdcc-makelib --bc-target=ZDoom libc -c -o ir/libc.ir
gdcc-makelib --bc-target=ZDoom libGDCC -c -o ir/libGDCC.ir
gdcc-ld --bc-target=ZDoom --bc-zdacs-init-delay --alloc-min Sta "" 1000000000 ir/libc.ir ir/libGDCC.ir acs/libc.bin
Assuming the "ir" and "acs" folders exist wherever you run these commands, of course. The source code is in the GDCC folder, under "lib"
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Effective ACS IWAD Detection

Post by Nash »

Gez explains the jist of using game filters in this post: http://forum.zdoom.org/viewtopic.php?f= ... er#p902044
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: Effective ACS IWAD Detection

Post by The Zombie Killer »

That was the very post that inspired the current method used in ACS-X. I ended up going with LANGUAGE over individual ACS libraries for each game, because it ended up being cleaner and much easier to manage

EDIT: By the way, your GetDoomVersion function can be simplified to something like this:

Code: Select all

enum
{
    DOOMVERSION_UNKNOWN,
    DOOMVERSION_DOOM1,
    DOOMVERSION_DOOM2,
    DOOMVERSION_FREEDOOM,
};

function int GetDoomVersion(void)
{
    switch (GetGame())
    {
        case GAME_DOOM:
        case GAME_DOOM_BFG:
        case GAME_DOOM_ULTIMATE:
            return DOOMVERSION_DOOM1;
        
        case GAME_DOOM2:
        case GAME_DOOM2_PLUTONIA:
        case GAME_DOOM2_TNT:
        case GAME_DOOM2_BFG:
            return DOOMVERSION_DOOM2;
        
        case GAME_FREEDOOM_DEMO:
        case GAME_FREEDOOM_PHASE1:
        case GAME_FREEDOOM_PHASE2:
        case GAME_FREEDOOM_FREEDM:
            return DOOMVERSION_FREEDOOM;
        
        default:
            return DOOMVERSION_UNKNOWN;
    }
}
 
GleasSpty
Posts: 48
Joined: Tue Apr 19, 2016 6:17 am

Re: Effective ACS IWAD Detection

Post by GleasSpty »

Awesome, thanks!
Locked

Return to “Editing (Archive)”