OUCH
I really think you need to take some C classes, friend
Lesson #1.
A
function is something like
void DoSomething (int parameter1, float parameter2)
or
int DoSomethingElse (Vector parameter1)
in fact it can take any form you want, either it does not return a value - and then the type is "void" - or it returns a value after execution, and then the type is int, float, or any data type you want.
When a function is called in the code, the computer branches the execution right into it, executes the function, and once the function is finished returns to the point from where it was called.
Functions usually end up with the statement "return". When the function has a return type of "void", then "return" does not need to be called. The code will just exit the function as soon as the last closing brace } is reached. On functions that are required to return a value, though, the return value must be explicitly passed as a parameter of the "return" instruction. Example:
return (-1); // this function will return -1
or
return (my_variable); // this function will return the value of my_variable
A
data type is an identifier that tells what type of data you are allowed to put in a variable.
Example:
int variable_1; // in this variable you can put integer numbers only (like 1 or 2)
float variable_2; // in this variable you are allowed to put floating-point numbers (like 0.5)
char variable_3; // in this one you can put a character like 'a' or 'b'
It's not that exact. In fact in "char" variables you are also allowed to put integer numbers, like in "int" variables you can put other forms of data, like pointers, etc. All comes down to the size the variable takes in memory. "int" variables eat up 4 bytes, hence 4*8=32 bit of data (32 times 0 and 1s). That's why you are also allowed to store pointers in them, since a pointer is usually 4 bytes large too. On the other hand, "char" variables eat just 1 byte, hence 8 bits. With only 8 bits to describe a number you cannot go above +/-127 (if you keep the last bit to describe the sign, thus the data will be said
signed), or 255 (if you eat the whole 8 bits for your number, and then the data will be said
unsigned and you will have only positive numbers in it). With so few you cannot store pointers which are big numbers, and usually go way above 255.
You can also arrange your data in arrays. Arrays are just a set of variables of the same type put next to each other in memory. Example:
char variable1[32]; // this is an array of "char" variables
In this one you can put 32 characters, or 32 integer numbers provided each of them does not exceed 127 (since "char" means
signed char). You can hence put characters
char variable1[32] = "abcdef"; // like some text (you're not forced to eat up all the 32 slots)
Or integer values
char variable1[32] = {1,45,53,23,123,6,84,22}; // as long as they don't go above 127
Char, int, long, short, float, double, void, are standard C data types. But in his code, a programmer may need to use more complex forms of data. Like, for example, a vector. A vector must be described by 3 real (floating point) numbers, and that obviously cannot fit in one single variable. One could do this:
float x_component;
float y_component;
float z_component;
but that's not very practical. The C language provides much better mechanisms for describing more complex types of data.
A
struct (abbreviation for "structure") is when you tell the C compiler: "hey, from now on, I will make use of a new type of data that you don't know yet. It will be named XXXX and it will be composed of : this, that and that."
Example:
typedef struct
{
char variable1; // first member of my struct will be a "char" variable
float variable2; // second member will be a floating point variable
int variable3; // and the third slot will be occupied with an integer number.
} my_struct;
Here you say to the compiler: look, I am telling you of this new data type I am going to use. It's called "my_struct". In it you will find
1st - a char variable
2nd - a float variable
3rd and last - an int variable.
And from then on, in your code, you can use this new struct, the compiler will know about it. For example, at the beginning of a function, you can declare:
my_struct blablablah;
just like you would declare
float variable1;
or any other form of data. Since your struct has been
defined, the compiler will know about it. You will then be able to access your struct's
members like this:
blablablah.variable1 = 'a'; // put 'a' in the 1st member of my struct
blablablah.variable2 = 0.5; // put 0.5 in the 2nd one (it's a float variable)
blablablah.variable3 = 435264; // and so on.
In the Half-Life SDK, the Vector data type can be seen as a custom struct, having members named x, y and z. You can do:
Vector some_vector; // declare a new vector
some_vector.x = 0.324; // access x component
some_vector.y = 5643.546; // access y component
some_vector.z = 32.3; // access z component
(in fact it's a bit more complex. Vector is not only a
struct, it's a
class. A class can be seen like a struct, in which you put not only variables, but also
functions, like Length() for example.)
Now look at this:
Code:
typedef struct
{
int iId; // the weapon ID value
char weapon_name[64]; // name of the weapon when selecting it
char model_name[64]; // Model Name to separate CS Weapons
float primary_min_distance; // 0 = no minimum
float primary_max_distance; // 9999 = no maximum
float secondary_min_distance; // 0 = no minimum
float secondary_max_distance; // 9999 = no maximum
bool can_use_underwater; // can use this weapon underwater
bool primary_fire_hold; // hold down primary fire button to use?
float primary_charge_delay; // time to charge weapon
int iPrice; // Price when buying
int min_primary_ammo;
int iTeamStandard; // Used by Team (Number) (standard map)
int iTeamAS; // Used by Team (AS map)
int iBuyGroup; // Group in Buy Menu (standard map)
int iBuySelect; // Select Item in Buy Menu (standard map)
// Whistler: added for Cs 1.6
int iNewBuySelectT;
int iNewBuySelectCT;
bool bShootsThru; // Can shoot thru Walls
} bot_weapon_select_t;
Question 1. Is that a function or is that a structure ?
A structure, obviously. Its name is bot_weapon_select_t and it has the aforementioned members.
Question 2. What must buy_shortcut be ?
buy_shortcut must be a member of the bot_weapon_select_t structure, so that you can use it in further declarations of bot_weapon_select_t variables.
Question 3. How do you need to define buy_shortcut ?
Simply by adding it to the list with the other members of the bot_weapon_select_t structure.
If you answer these questions right, you will know enough to fix your problem. If you CANNOT answer them right, IMO it's too early for you to take on the development of a bot as complicated as podbot
The answer is provided in
clear text, btw