HLFX.Ru Forum
Показать все 3 сообщений этой темы на одной странице

HLFX.Ru Forum (https://hlfx.ru/forum/index.php)
- Half-Life SDK (https://hlfx.ru/forum/forumdisplay.php?forumid=8)
-- Having more than 32 weapons in Half-Life mod? (https://hlfx.ru/forum/showthread.php?threadid=5299)


Отправлено Napoleon321 07-07-2019 в 07:05:

Half-Life Having more than 32 weapons in Half-Life mod?

Hello All, first I would like to apologize for writing in English, my Russian is awful and if I try to write you'll have a fun time reading.

I have the following issue:

Having more than 32 weapons in Half-Life mod.

For quite some time I was trying to incorporate more than 32 weapon in my Half-Life mod. I noticed there's a dependency between the number of "WEAPON_SUIT" and the number of allowed weapons on the mod.

For example by default the number of the suit is 31:

.\dlls\weapons.h

C++ Source Code:
#define WEAPON_SUIT 31 // ?????


.\common\cdll_dll.h
C++ Source Code:
#define WEAPON_SUIT 31


Note that I already have the Max_WEAPONS redefined as 64 defined (I know that the hard limit for max weapons in the engine is actually 64:

C++ Source Code:
#define MAX_WEAPONS 64


The definition for all weapons is the following:

C++ Source Code:
#define WEAPON_ALLWEAPONS (~(1<<WEAPON_SUIT))


So we're dependent on the number of the WEAPON_SUIT. If I try to add weapon with number above 32, I get the game to crash/freeze. I have double checked and it's not with the weapon code or with the definitions for that specific weapon (I obviously commented out another weapon and placed my code over that weapon's place and it all worked fine).
If I add weapon beyond 32, I don't get errors in the compiler and the "client" and "server" library compile well. So I started playing around with the definitions.

If I put WEAPON_SUIT to greater value than 31, (example 64, 128 or 256; I tested other values from 33 to 256 - the result is the same).
I can define more than 32 weapons for the mod, however there are other issues arising after that...

1. I get the following warnings when I compile:

1>d:\sdk_\dlls\player.cpp(761): warning C4293: '<<' : shift count negative or too big, undefined behavior
1>d:\sdk_\dlls\items.cpp(188): warning C4293: '<<' : shift count negative or too big, undefined behavior
1>d:\sdk_\dlls\healthkit.cpp(199): warning C4293: '<<' : shift count negative or too big, undefined behavior
1>d:\sdk_\dlls\h_battery.cpp(121): warning C4293: '<<' : shift count negative or too big, undefined behavior
1>d:\sdk_\dlls\bot.cpp(882): warning C4293: '<<' : shift count negative or too big, undefined behavior

Those warnings are related to lines containing "pev->weapons & (1<
So clearly changing the number of WEAPON_SUIT is the issue here.

2. When I start a game with the compiled libraries (with more than 32 weapons defined), I observe stage behaviors with the weapons above 32:

a) game crashing / freezing upon spawning / getting that weapon.
b) game working OK, however the gun has no animations, sprites and sounds.
c) game working, but with no sprites for the game in general.

So I guess the current definition does not support more than 32 (32-1).
I've searched everywhere for example on how to change the definitions properly to support more than 32 bytes (including based on warning C4293) and I'm unable to find a solution or workaround.

I know there are mods out there that have the functionality implemented - I've seen it in HL Weapon's Edition, XASH, Half-Life: Enhanced and few others; and I was wondering did anyone faced the same issue like me?
Have you been able to find a workaround for this one?

Any inside on this would be greatly appreciated.


Отправлено XaeroX 07-07-2019 в 07:22:

Napoleon321
You oughtn't to blindly increase the value of WEAPON_SUIT, because there is a hard limit of 32 bits in an integer variable.
Please read this tutorial, it explains the problem and gives a solution:
https://hlfx.ru/forum/showthread.php?s=&threadid=5053

__________________


Отправлено Napoleon321 22-11-2021 в 08:47:

Hello, I'm sorry for the bump, just for completion sake:

I was not able to follow the tutorial by Дядя Миша , however...

This one actually works (with few extra tweaks) - http://www.half-life.ru/forum/showt...p?threadid=6129

__________________
FlatLine Arena | Tutorials

If you don't like something, MOD it!


Временная зона GMT. Текущее время 09:14.
Показать все 3 сообщений этой темы на одной странице

На основе vBulletin версии 2.3.0
Авторское право © Jelsoft Enterprises Limited 2000 - 2002.
Дизайн и программирование: Crystice Softworks © 2005 - 2024