i have some optimizations for the buycode...
Code:
--- realbot/bot_buycode.cpp 2004-07-08 05:04:57.000000000 -0400
+++ realbot.tmp/bot_buycode.cpp 2004-07-20 10:23:26.000000000 -0400
@@ -166,7 +166,7 @@
if (FUNC_BotHasWeapon (pBot, pBot->ipFavoPriWeapon) == false)
{
if (GoodWeaponForTeam (pBot->ipFavoPriWeapon, pBot->iTeam))
- if (PriceWeapon (pBot->ipFavoPriWeapon) < money)
+ if (wapen_tabel[wapen_tabel[(pBot->ipFavoPriWeapon)].iIdIndex].price < money)
{
// Buy favorite weapon
buy_weapon = pBot->ipFavoPriWeapon;
@@ -229,7 +229,8 @@
pBot->buy_primary = false;
// depending on amount of money we have left buy a secondary weapon
- int iMoneyLeft = money - PriceWeapon (buy_weapon);
+ int iMoneyLeft = money -
+wapen_tabel[wapen_tabel[(buy_weapon)].iIdIndex].price;
// TODO: this should be dependant on something else... not only money
if (iMoneyLeft > 500)
@@ -248,7 +249,8 @@
if (FUNC_BotHasWeapon (pBot, pBot->ipFavoSecWeapon) == false)
if (GoodWeaponForTeam (pBot->ipFavoPriWeapon, pBot->iTeam))
{
- if (PriceWeapon (pBot->ipFavoSecWeapon) < money)
+ if
+(wapen_tabel[wapen_tabel[(pBot->ipFavoSecWeapon)].iIdIndex].price < money)
{
// Buy favorite weapon
buy_weapon = pBot->ipFavoSecWeapon;
@@ -330,7 +332,7 @@
else if (pBot->buy_grenade)
{
// Buy grenade
- if (money > wapen_tabel[ListIdWeapon (CS_WEAPON_HEGRENADE)].price)
+ if (money > wapen_tabel[wapen_tabel[(CS_WEAPON_HEGRENADE)].iIdIndex].price)
buy_weapon = CS_WEAPON_HEGRENADE;
pBot->buy_grenade = false;
@@ -338,7 +340,7 @@
else if (pBot->buy_flashbang > 0)
{
// Buy flashbang
- if (money > wapen_tabel[ListIdWeapon (CS_WEAPON_FLASHBANG)].price)
+ if (money > wapen_tabel[wapen_tabel[ (CS_WEAPON_FLASHBANG)].iIdIndex].price)
{
buy_weapon = CS_WEAPON_FLASHBANG;
--- realbot/IniParser.cpp 2004-07-02 12:43:34.000000000 -0400
+++ realbot.tmp/IniParser.cpp 2004-07-20 11:02:00.000000000 -0400
@@ -1120,6 +1120,7 @@
{
wapen_tabel[cl].iId = -1;
wapen_tabel[cl].price = -1;
+ wapen_tabel[cl].iIdIndex = -1;
wapen_tabel[cl].priority = -1;
}
@@ -1163,6 +1164,7 @@
}
wapen_tabel[weapon_id].iId = section;
+ wapen_tabel[wapen_tabel[weapon_id].iId].iIdIndex = weapon_id;
// SECURE WEAPON ID
// 02/07/04 - Stefan - Should be removed now...
--- realbot/bot.h 2004-07-03 12:36:51.000000000 -0400
+++ realbot.tmp/bot.h 2004-07-20 10:18:10.000000000 -0400
@@ -36,6 +36,7 @@
int iId; // the weapon ID value
int price; // Price of weapon
int priority; // Priority to buy this weapon
+ int iIdIndex;
} weapon_price_table;
// BOT SPECIFIC / AUDIOABLE / VISUAL PROPERTIES
provides table lookup for weapon_id -> wapen_tabel
instead of a for loop