]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'Mario/weaponentities' into 'master'
authorMario <zacjardine@y7mail.com>
Sun, 14 Aug 2016 02:31:49 +0000 (02:31 +0000)
committerMario <zacjardine@y7mail.com>
Sun, 14 Aug 2016 02:31:49 +0000 (02:31 +0000)
Merge branch Mario/weaponentities (XL merge request)

Purges most checks like weaponentities[0], allowing for potentially multiple weapon entities.

See merge request !347

1  2 
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/weapons/weapon.qh
qcsrc/common/weapons/weapon/porto.qc
qcsrc/server/bot/default/scripting.qc
qcsrc/server/weapons/selection.qc
qcsrc/server/weapons/weaponsystem.qc

index 0a6387fe446ed5ace5527f8c9cb7cbfb7afd8b67,a3d68a2eb0cf51818c6511de79acb17f0806eb55..0f0ecb471943ff4623627aa9cbcd9206676bf9d5
@@@ -459,7 -459,7 +459,7 @@@ spawnfunc(nexball_team
  
  void nb_spawnteam(string teamname, float teamcolor)
  {
 -      LOG_TRACE("^2spawned team ", teamname, "\n");
 +      LOG_TRACE("^2spawned team ", teamname);
        entity e = new(nexball_team);
        e.netname = teamname;
        e.cnt = teamcolor;
@@@ -762,14 -762,14 +762,14 @@@ void W_Nexball_Touch(entity this, entit
        delete(this);
  }
  
- void W_Nexball_Attack(entity actor, float t)
+ void W_Nexball_Attack(entity actor, .entity weaponentity, float t)
  {
        entity ball;
        float mul, mi, ma;
        if(!(ball = actor.ballcarried))
                return;
  
-       W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+       W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
        tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, NULL);
        if(trace_startsolid)
        {
  
  vector trigger_push_calculatevelocity(vector org, entity tgt, float ht);
  
- void W_Nexball_Attack2(entity actor)
+ void W_Nexball_Attack2(entity actor, .entity weaponentity)
  {
        if(actor.ballcarried.enemy)
        {
                entity _ball = actor.ballcarried;
-               W_SetupShot(actor, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
+               W_SetupShot(actor, weaponentity, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0);
                DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
                setthink(_ball, W_Nexball_Think);
                _ball.nextthink = time;
        if(!autocvar_g_nexball_tackling)
                return;
  
-       W_SetupShot(actor, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
+       W_SetupShot(actor, weaponentity, false, 2, SND_NB_SHOOT2, CH_WEAPON_A, 0);
        entity missile = new(ballstealer);
  
        missile.owner = actor;
@@@ -881,19 -881,19 +881,19 @@@ METHOD(BallStealer, wr_think, void(Ball
              }
              else
              {
-                 W_Nexball_Attack(actor, -1);
+                 W_Nexball_Attack(actor, weaponentity, -1);
                  weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
              }
      if(fire & 2)
          if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire))
          {
-             W_Nexball_Attack2(actor);
+             W_Nexball_Attack2(actor, weaponentity);
              weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
          }
  
      if(!(fire & 1) && actor.metertime && actor.ballcarried)
      {
-         W_Nexball_Attack(actor, time - actor.metertime);
+         W_Nexball_Attack(actor, weaponentity, time - actor.metertime);
          // DropBall or stealing will set metertime back to 0
          weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
      }
index 021d6ddfa91dc895a0ebd9902b56dc49db23f534,f189d2652889a96d0d84a2d4d903bcce85f3c679..ea46be5f12e7343152b8920cc2f7089d9f6253bf
@@@ -247,7 -247,7 +247,7 @@@ void Monster_Sound_Precache(string f
        {
                if(tokenize_console(s) != 3)
                {
 -                      LOG_TRACE("Invalid sound info line: ", s, "\n");
 +                      LOG_TRACE("Invalid sound info line: ", s);
                        continue;
                }
                PrecacheGlobalSound(strcat(argv(1), " ", argv(2)));
@@@ -302,7 -302,7 +302,7 @@@ bool Monster_Sounds_Load(entity this, s
        fh = fopen(f, FILE_READ);
        if(fh < 0)
        {
 -              LOG_TRACE("Monster sound file not found: ", f, "\n");
 +              LOG_TRACE("Monster sound file not found: ", f);
                return false;
        }
        while((s = fgets(fh)))
@@@ -899,13 -899,17 +899,17 @@@ void Monster_Remove(entity this
        if(IS_CLIENT(this))
                return; // don't remove it?
  
-       .entity weaponentity = weaponentities[0];
        if(!this) { return; }
  
        if(!MUTATOR_CALLHOOK(MonsterRemove, this))
                Send_Effect(EFFECT_ITEM_PICKUP, this.origin, '0 0 0', 1);
  
-       if(this.(weaponentity)) { delete(this.(weaponentity)); }
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               .entity weaponentity = weaponentities[slot];
+               if(this.(weaponentity))
+                       delete(this.(weaponentity));
+       }
        if(this.iceblock) { delete(this.iceblock); }
        WaypointSprite_Kill(this.sprite);
        delete(this);
index fdbddc80a90e88b59d95c6924a71a54e205d4218,fc1eb3b6b8243ac4073082c4bf68a1b318f8cb7f..d785124a76e6698bc139ffe2d38134a975cba50c
@@@ -890,7 -890,8 +890,8 @@@ void toss_nade(entity e, bool set_owner
  
        makevectors(e.v_angle);
  
-       W_SetupShot(e, false, false, SND_Null, CH_WEAPON_A, 0);
+       // NOTE: always throw from first weapon entity?
+       W_SetupShot(e, weaponentities[0], false, false, SND_Null, CH_WEAPON_A, 0);
  
        Kill_Notification(NOTIF_ONE_ONLY, e, MSG_CENTER, CPID_NADES);
  
@@@ -1174,7 -1175,7 +1175,7 @@@ CLASS(NadeOffhand, OffhandWeapon
                if (held_nade)
                {
                        player.nade_timer = bound(0, (time - held_nade.nade_time_primed) / autocvar_g_nades_nade_lifetime, 1);
 -                      // LOG_TRACEF("%d %d\n", player.nade_timer, time - held_nade.nade_time_primed);
 +                      // LOG_TRACEF("%d %d", player.nade_timer, time - held_nade.nade_time_primed);
                        makevectors(player.angles);
                        held_nade.velocity = player.velocity;
                        setorigin(held_nade, player.origin + player.view_ofs + v_forward * 8 + v_right * -8 + v_up * 0);
index 54d05d4d10cc182fe4a124a0c14db3e1d0896c45,739ec1c32fab4e859bbaeac0a586d56ad55e6305..9465d5dcba6b70c5760cf023509650fa9a41840d
@@@ -107,9 -107,9 +107,9 @@@ CLASS(Weapon, Object
      /** (CLIENT) impact effect for weapon explosion */
      METHOD(Weapon, wr_impacteffect, void(Weapon this, entity actor)) {}
      /** (SERVER) called whenever a player dies */
-     METHOD(Weapon, wr_playerdeath, void(Weapon this, entity actor)) {}
+     METHOD(Weapon, wr_playerdeath, void(Weapon this, entity actor, .entity weaponentity)) {}
      /** (SERVER) logic to run when weapon is lost */
-     METHOD(Weapon, wr_gonethink, void(Weapon this, entity actor)) {}
+     METHOD(Weapon, wr_gonethink, void(Weapon this, entity actor, .entity weaponentity)) {}
      /** (ALL)    dump weapon cvars to config in data directory (see: sv_cmd dumpweapons) */
      METHOD(Weapon, wr_config, void(Weapon this)) {}
      /** (CLIENT) weapon specific zoom reticle */
@@@ -158,7 -158,7 +158,7 @@@ CLASS(WeaponPickup, Pickup
      {
          bool b = Item_GiveTo(item, player);
          if (b) {
 -            LOG_TRACEF("entity %i picked up %s\n", player, this.m_name);
 +            LOG_TRACEF("entity %i picked up %s", player, this.m_name);
          }
          return b;
      }
index 67463e265d77b15189cde0bc466a2be143c0f1ff,9bbc669e3827756b6ddb792e80421095a6bf70d7..fcb8952ef7bb1d0c9c96ea6780fc8c014148c954
@@@ -240,11 -240,11 +240,11 @@@ void W_Porto_Touch(entity this, entity 
        }
  }
  
- void W_Porto_Attack(entity actor, float type)
+ void W_Porto_Attack(entity actor, .entity weaponentity, float type)
  {
        entity gren;
  
-       W_SetupShot(actor, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0);
+       W_SetupShot(actor, weaponentity, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0);
        // always shoot from the eye
        w_shotdir = v_forward;
        w_shotorg = actor.origin + actor.view_ofs + ((w_shotorg - actor.origin - actor.view_ofs) * v_forward) * v_forward;
@@@ -310,7 -310,7 +310,7 @@@ METHOD(PortoLaunch, wr_think, void(enti
          if(!actor.porto_forbidden)
          if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
          {
-             W_Porto_Attack(actor, 0);
+             W_Porto_Attack(actor, weaponentity, 0);
              weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
          }
  
          if(!actor.porto_forbidden)
          if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(porto, refire)))
          {
-             W_Porto_Attack(actor, 1);
+             W_Porto_Attack(actor, weaponentity, 1);
              weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
          }
      }
          if(!actor.porto_forbidden)
          if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire)))
          {
-             W_Porto_Attack(actor, -1);
+             W_Porto_Attack(actor, weaponentity, -1);
              weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
          }
      }
@@@ -378,7 -378,7 +378,7 @@@ METHOD(PortoLaunch, wr_resetplayer, voi
  #endif
  #ifdef CSQC
  METHOD(PortoLaunch, wr_impacteffect, void(entity this, entity actor)) {
 -    LOG_WARN("Since when does Porto send DamageInfo?\n");
 +    LOG_WARN("Since when does Porto send DamageInfo?");
  }
  #endif
  #endif
index ffb7e58132d0348a439d62d866fc84cb8fffddd0,349dc1cdcb0c8eefb55795a904222407477c3746..e111b2ab4f043f5174b270b5090f6190a3dfb5c1
@@@ -20,7 -20,7 +20,7 @@@ void bot_clearqueue(entity bot
                return;
        buf_del(bot.bot_cmdqueuebuf);
        bot.bot_cmdqueuebuf_allocated = false;
 -      LOG_TRACE("bot ", bot.netname, " queue cleared\n");
 +      LOG_TRACE("bot ", bot.netname, " queue cleared");
  }
  
  void bot_queuecommand(entity bot, string cmdstring)
@@@ -1058,7 -1058,7 +1058,7 @@@ float bot_cmd_debug_assert_canfire(enti
  {
        float f = bot_cmd.bot_cmd_parm_float;
  
-       int slot = 0;
+       int slot = 0; // TODO: unhardcode?
        .entity weaponentity = weaponentities[slot];
        if(this.(weaponentity).state != WS_READY)
        {
index aa6666e3db20a76dfb15234519e796b8f39ac365,b05c0621b534d2dca5c83a840824532881cad9af..ff5eaa59a41e187b7a29f4f6939a4f042b7d8806
@@@ -29,7 -29,7 +29,7 @@@ void Weapon_whereis(Weapon this, entit
                        continue;
                entity wp = WaypointSprite_Spawn(
                        WP_Weapon,
 -                      1, 0,
 +                      -2, 0,
                        NULL, it.origin + ('0 0 1' * it.maxs.z) * 1.2,
                        cl, 0,
                        NULL, enemy,
@@@ -272,8 -272,11 +272,11 @@@ void W_SwitchWeapon(entity this, Weapo
        }
        else if(!forbidWeaponUse(this)) {
                entity actor = this;
-               .entity weaponentity = weaponentities[0]; // TODO: unhardcode
-               w.wr_reload(w, actor, weaponentity);
+               for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+               {
+                       .entity weaponentity = weaponentities[slot];
+                       w.wr_reload(w, actor, weaponentity);
+               }
        }
  }
  
index aeb5574b392b47a33be53fa5339de773023262fa,1a4e797f52d3da41d3625e224e0c91983748cd87..c0ed81e68173da34f4c819e6701e924cf2f6f748
@@@ -417,11 -417,10 +417,10 @@@ bool forbidWeaponUse(entity player
  
  .bool hook_switchweapon;
  
- void W_WeaponFrame(Player actor)
+ void W_WeaponFrame(Player actor, .entity weaponentity)
  {
      TC(Player, actor);
      TC(PlayerState, PS(actor));
-       .entity weaponentity = weaponentities[0];  // TODO: unhardcode
        entity this = actor.(weaponentity);
        if (frametime) actor.weapon_frametime = frametime;
  
                switch (this.state)
                {
                        default:
 -                              LOG_WARNF("unhandled weaponentity (%i) state for player (%i): %d\n", this, actor, this.state);
 +                              LOG_WARNF("unhandled weaponentity (%i) state for player (%i): %d", this, actor, this.state);
                                break;
                        case WS_INUSE:
                        case WS_RAISE:
                        }
                        else if (e)
                        {
-                               e.wr_gonethink(e, actor);
+                               e.wr_gonethink(e, actor, weaponentity);
                        }
                }
  
        }
  }
  
- void W_AttachToShotorg(entity actor, entity flash, vector offset)
+ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector offset)
  {
-       .entity weaponentity = weaponentities[0];
        flash.owner = actor;
        flash.angles_z = random() * 360;
  
@@@ -690,10 -688,9 +688,9 @@@ void W_ReloadedAndReady(Weapon thiswep
        w_ready(wpn, actor, weaponentity, PHYS_INPUT_BUTTON_ATCK(actor) | (PHYS_INPUT_BUTTON_ATCK2(actor) << 1));
  }
  
- void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound)
+ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound)
  {
      TC(Sound, sent_sound);
-       .entity weaponentity = weaponentities[0];
        // set global values to work with
        Weapon e = PS(actor).m_weapon;