fixed bugs in dod_get_user_weapon

This commit is contained in:
Lukasz Wlasinksi 2004-07-30 15:20:40 +00:00
parent c6c95f2443
commit 1551f500e3
4 changed files with 79 additions and 41 deletions

View File

@ -34,48 +34,48 @@
/* Weapon names aren't send in WeaponList message in DoD */
weapon_t weaponData[] = {
{ false,false,"mortar","mortar" },
{ true,true,"amerknife","knife" }, // aknife->bknife
{ false,true,"gerknife","knife" },
{ false,false,"colt","Colt" },
{ false,false,"luger","Luger" },
{ true,false,"garand","Garand" }, // Garand->Garand butt
{ false,false,"scopedkar","scoped K98" },
{ false,false,"thompson","Thompson" },
{ false,false,"mp44","STG44" },
{ false,false,"spring","Springfield" },
{ true,false,"kar","K98" }, // KAR->KAR bayonet
{ false,false,"bar","BAR" },
{ false,false,"mp40","MP40" },
{ false,false,"grenade","handgrenade" },
{ false,false,"grenade2","stickgrenade" },
{ false,false,"stickgrenade_ex","stickgrenade_ex" },
{ false,false,"handgrenade_ex","handgrenade_ex" },
{ false,false,"mg42","MG42" },
{ false,false,"30cal",".30 cal" },
{ false,true,"spade","spade" },
{ true,false,"m1carbine","M1 Carbine" }, // M1 Carbine->Folding Carbine
{ false,false,"mg34","MG34" },
{ false,false,"greasegun","Greasegun" },
{ true,false,"fg42","FG42" }, // FG42 -> scoped FG42
{ true,false,"k43","K43" },
{ true,false,"enfield","Enfield" }, // Enfield->Scoped Enfield->Enfield bayonet
{ false,false,"sten","Sten" },
{ false,false,"bren","Bren" },
{ false,false,"webley","Webley" },
{ false,false,"bazooka","Bazooka" },
{ false,false,"pschreck","Panzerschrek" },
{ false,false,"piat","Piat" },
{ false,false,"scoped_fg42","scoped FG42" },
{ false,false,"mortar","mortar",0 },
{ true,true,"amerknife","knife",0 }, // aknife->bknife
{ false,true,"gerknife","knife",0 },
{ false,false,"colt","Colt",4 },
{ false,false,"luger","Luger",4 },
{ true,false,"garand","Garand",3 }, // Garand->Garand butt
{ false,false,"scopedkar","scoped K98",3 },
{ false,false,"thompson","Thompson",1 },
{ false,false,"mp44","STG44",6 },
{ false,false,"spring","Springfield",5 },
{ true,false,"kar","K98",3 }, // KAR->KAR bayonet
{ false,false,"bar","BAR",6 },
{ false,false,"mp40","MP40",1 },
{ false,false,"grenade","handgrenade",9 },
{ false,false,"grenade2","stickgrenade",11 },
{ false,false,"stickgrenade_ex","stickgrenade_ex",11 },
{ false,false,"handgrenade_ex","handgrenade_ex",9 },
{ false,false,"mg42","MG42",7 },
{ false,false,"30cal",".30 cal",8 },
{ false,true,"spade","spade",0 },
{ true,false,"m1carbine","M1 Carbine",2 }, // M1 Carbine->Folding Carbine
{ false,false,"mg34","MG34",2 },
{ false,false,"greasegun","Greasegun",1 },
{ true,false,"fg42","FG42",6 }, // FG42 -> scoped FG42
{ true,false,"k43","K43",2 },
{ true,false,"enfield","Enfield",3 }, // Enfield->Scoped Enfield->Enfield bayonet
{ false,false,"sten","Sten",1 },
{ false,false,"bren","Bren",6 },
{ false,false,"webley","Webley",4 },
{ false,false,"bazooka","Bazooka",13 },
{ false,false,"pschreck","Panzerschrek",13 },
{ false,false,"piat","Piat",13 },
{ false,false,"scoped_fg42","scoped FG42",6 },
{ false,false,"fcarbine","Folding Carbine" },
{ false,true,"bayonet","K98 bayonet" }, // KAR bayonet
{ false,false,"scoped_enfield","scoped Enfield"},
{ false,false,"mills_bomb","mills bomb" },
{ false,true,"brit_knife","knife" },
{ false,true,"garandbutt","Garand butt" }, // Garand butt
{ false,true,"enf_bayonet","Enfield bayonet" },
{ false,false,"mortar","mortar" }, // mortar new id
{ false,true,"k43butt","K43 butt" },
{ false,true,"bayonet","K98 bayonet",0 }, // KAR bayonet
{ false,false,"scoped_enfield","scoped Enfield",3 },
{ false,false,"mills_bomb","mills bomb",9 },
{ false,true,"brit_knife","knife",0 },
{ false,true,"garandbutt","Garand butt",0 }, // Garand butt
{ false,true,"enf_bayonet","Enfield bayonet",0 },
{ false,false,"mortar","mortar",0 }, // mortar new id
{ false,true,"k43butt","K43 butt",0 },
};
/* Function will select correct id */

View File

@ -52,6 +52,7 @@ struct weapon_t {
bool melee;
char logname[16];
char name[32];
int ammoSlot;
};
extern bool rankBots;
@ -64,6 +65,8 @@ void Client_ResetHUD_End(void*);
void Client_ObjScore(void*);
void Client_TeamScore(void*);
void Client_RoundState(void*);
void Client_AmmoX(void*);
void Client_AmmoShort(void*);
typedef void (*funEventCall)(void*);

View File

@ -69,6 +69,9 @@ int gmsgTeamScore;
int gmsgScoreShort;
int gmsgPTeam;
int gmsgAmmoX;
int gmsgAmmoShort;
RankSystem g_rank;
Grenades g_grenades;
@ -100,6 +103,9 @@ struct sUserMsg {
{ "ScoreShort",&gmsgScoreShort,NULL,false },
{ "PTeam",&gmsgPTeam,NULL,false },
{ "AmmoX",&gmsgAmmoX,Client_AmmoX,false},
{ "AmmoShort",&gmsgAmmoShort,Client_AmmoShort,false},
{ 0,0,0,false }
};

View File

@ -102,11 +102,13 @@ void Client_CurWeapon(void* mValue){
if ( !iState || !isModuleActive() )
break;
int iClip = *(int*)mValue;
mPlayer->current = iId;
if ( weaponData[iId].needcheck ){
iId = get_weaponid(mPlayer);
mPlayer->current = iId;
}
if (iClip > -1) {
if ( mPlayer->current == 17 ){
if ( iClip+2 == mPlayer->weapons[iId].clip)
@ -186,3 +188,30 @@ void Client_Health_End(void* mValue){
}
}
void Client_AmmoX(void* mValue){
static int iAmmo;
switch (mState++){
case 0:
iAmmo = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (iAmmo == weaponData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue;
}
}
void Client_AmmoShort(void* mValue){
static int iAmmo;
switch (mState++){
case 0:
iAmmo = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (iAmmo == weaponData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue;
}
}