From 2f345b1d6e130177efe4fa47d5b2bd11f352ce85 Mon Sep 17 00:00:00 2001 From: jacopo grandi Date: Thu, 25 Feb 2021 16:36:55 +0100 Subject: guillotined dead code --- gst/info.c | 629 +------------------------------------------------------------ 1 file changed, 2 insertions(+), 627 deletions(-) (limited to 'gst/info.c') diff --git a/gst/info.c b/gst/info.c index 721863b..0a7222d 100644 --- a/gst/info.c +++ b/gst/info.c @@ -41,240 +41,7 @@ void info_unit_init (info_unit *u) { for(int i=0; i<16; u->augs[i] = -1, i++); for(int i=0; i<34; u->levels[i] = 0, i++); } - -float info_unit_get_capacity(infos *info, info_unit *u) { - float sum = 0; - int lc = u->levels[LEVEL_CHASSIS]; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].add_capacity[lvl]; - } - } - int lvl = u->levels[LEVEL_BATTERY]; - sum += info->batteries[u->battery].capacity[lvl]; - return sum; -} - -float info_unit_get_upkeep(infos *info, info_unit *u) { - float sum = 0; - int lc = u->levels[LEVEL_CHASSIS]; - int lbr = u->levels[LEVEL_BRAIN]; - for(int i=0; i<8; i++) { - if (u->weapons[i] != -1 && info->chassis[u->chassis].slot_weapon[lc]) { - int lvl = u->levels[LEVEL_WEAPONS+i]; - sum += info->weapons[u->weapons[i]].upkeep[lvl]; - } - if (u->armor[i] != -1 && info->chassis[u->chassis].slot_armor[lc]) { - int lvl = u->levels[LEVEL_ARMOR+i]; - sum += info->armors[u->armor[i]].upkeep[lvl]; - } - } - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].upkeep[lvl]; - } - } - sum += info->chassis[u->chassis].upkeep[lc]; - sum += info->brains[u->brain].upkeep[lbr]; - return sum; -} - -float info_unit_get_weight (infos *info, info_unit *u) { - float sum = 0; - int lc = u->levels[LEVEL_CHASSIS]; - if (u->battery != -1) { - int lb = u->levels[LEVEL_BATTERY]; - sum += info->batteries[u->battery].weight[lb]; - } - for(int i=0; i<8; i++) { - if (u->weapons[i] != -1 && ichassis[u->chassis].slot_weapon[lc]) { - int lvl = u->levels[LEVEL_WEAPONS+i]; - sum += info->weapons[u->weapons[i]].weight[lvl]; - } - if (u->armor[i] != -1 && ichassis[u->chassis].slot_armor[lc]) { - int lvl = u->levels[LEVEL_ARMOR+i]; - sum += info->armors[u->armor[i]].weight[lvl]; - } - } - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].weight[lvl]; - } - } - return sum; -} - -float info_unit_get_dps (infos *info, info_unit *u) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<8; i++) { - if (u->weapons[i] != -1 && ichassis[u->chassis].slot_weapon[lc]) { - info_weapon *w = info->weapons+u->weapons[i]; - int lw = u->levels[LEVEL_WEAPONS+i]; - float damage = info_unit_get_damage(info, u, i); - sum += damage/w->cooldown[lw]; - } - } - return sum; -} - -float info_unit_get_health(infos *info, info_unit *u) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].add_hp[lvl]; - } - } - float mult = (1 + sum/100.0f); - if (mult < 0) mult = 0; - float ret = info->chassis[u->chassis].hp[lc] * mult; - return ret; -} - -float info_unit_get_speed(infos *info, info_unit *u) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].add_speed[lvl]; - } - } - sum += info->chassis[u->chassis].speed[lc]; - return sum; -} - -float info_unit_get_damage (infos *info, info_unit *u, int w) { - int lc = u->levels[LEVEL_CHASSIS]; - int damage_type = info->weapons[u->weapons[w]].damage_type; - float sum = 0; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].add_damage[damage_type][lvl]; - } - } - float mult = (1 + sum/100.0f); - if (mult < 0) mult = 0; - int lw = u->levels[LEVEL_WEAPONS+w]; - float dam = info->weapons[u->weapons[w]].damage[lw] * mult; - return dam; -} - -float info_unit_get_damage_target (infos *info, info_unit *u, int w, - info_unit *t) -{ - // u shoots at t with w, which is lol - int damage_type = info->weapons[u->weapons[w]].damage_type; - float reduction_perc = info_unit_get_armor(info, t, damage_type); - float damage = info_unit_get_damage(info, u, w); - float mult = (1 - reduction_perc / 100.0f); - return damage * mult; -} - -float info_unit_get_aoe (infos *info, info_unit *u, int w) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - //sum += info->augs[u->augs[i]].add_aoe[lvl]; - } - } - int lw = u->levels[LEVEL_WEAPONS+w]; - float dam = info->weapons[u->weapons[w]].aoe[lw] + sum; - return dam; -} - -float info_unit_get_knockback (infos *info, info_unit *u, int w) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - //sum += info->augs[u->augs[i]].add_knockback[lvl]; - } - } - int lw = u->levels[LEVEL_WEAPONS+w]; - float dam = info->weapons[u->weapons[w]].knockback[lw] + sum; - return dam; -} - -float info_unit_get_stun (infos *info, info_unit *u, int w) { - // TODO - return 0; -} - -float info_unit_get_cooldown(infos *info, info_unit *u, int w) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].add_cooldown[lvl]; - } - } - int lw = u->levels[LEVEL_WEAPONS+w]; - sum += info->weapons[u->weapons[w]].cooldown[lw]; - return sum; -} - -float info_unit_get_range(infos *info, info_unit *u, int w) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].add_range[lvl]; - } - } - int lw = u->levels[LEVEL_WEAPONS+w]; - sum += info->weapons[u->weapons[w]].range[lw]; - return sum; -} - -float info_unit_get_maxrange(infos *info, info_unit *u) { - int lc = u->levels[LEVEL_CHASSIS]; - float max = 0; - for(int i=0; ichassis[u->chassis].slot_weapon[lc]; i++) { - if (u->weapons[i] != -1) { - float range = info_unit_get_range(info, u, i); - if (range > max) { max = range; } - } - } - return max; -} - -float info_unit_get_charge_per_shot (infos *info, info_unit *u, int w) { - float sum = 0; - int lw = u->levels[LEVEL_WEAPONS+w]; - sum += info->weapons[u->weapons[w]].charge_per_shot[lw]; - return sum; -} - -float info_unit_get_armor(infos *info, info_unit *u, int d) { - int lc = u->levels[LEVEL_CHASSIS]; - float sum = 0; - for(int i=0; i<8; i++) { - if (u->armor[i] != -1 && ichassis[u->chassis].slot_armor[lc]) { - int lvl = u->levels[LEVEL_ARMOR+i]; - sum += info->armors[u->armor[i]].armor[d][lvl]; - } - } - for(int i=0; i<16; i++) { - if (u->augs[i] != -1 && info->chassis[u->chassis].slot_aug[lc]) { - int lvl = u->levels[LEVEL_AUGS+i]; - sum += info->augs[u->augs[i]].add_armor[d][lvl]; - } - } - return sum; -} - +/* float info_unit_get_cost (infos *info, info_unit *u) { // see design/notes.txt:implement cost function float sum = 0; @@ -321,78 +88,7 @@ float info_unit_get_cost (infos *info, info_unit *u) { return sum; } - - - -void weapon_init (info_weapon *w) { - strcpy(w->name, "nameless"); - for (int l=0; ldamage_type = 0; - w->weight[l] = 0; - w->cooldown[l] = 1; - w->damage[l] = 0; - w->range[l] = 0; - w->aoe[l] = 0; - w->knockback[l] = 0; - w->stun[l] = 0; - for (int i=0; i<7; i++) { w->reduce_armor[i][l]=0; } - w->upkeep[l] = 0; - w->charge_per_shot[l] = 0; - } -} - -void chassis_init (info_chassis *c) { - strcpy(c->name, "nameless"); - for (int l=0; lslot_weapon[l] = 0; - c->slot_armor[l] = 0; - c->slot_aug[l] = 0; - c->weight_max[l] = 0; - c->hp[l] = 0; - c->upkeep[l] = 0; - } -} - -void battery_init (info_battery *b) { - strcpy(b->name, "nameless"); - for (int l=0; lweight[l] = 0; - b->capacity[l] = 0; - b->recharge[l] = 0; - } -} - -void armor_init (info_armor *a) { - strcpy(a->name, "nameless"); - for (int l=0; lweight[l] = 0; - for (int i=0; i<7; i++) { a->armor[i][l]=0; } - a->upkeep[l] = 0; - } -} - -void aug_init (info_aug *a) { - strcpy(a->name, "nameless"); - for (int l=0; lweight[l] = 0; - for (int i=0; i<7; i++) { a->add_damage[i][l]=0; } - for (int i=0; i<7; i++) { a->add_armor[i][l]=0; } - a->add_range[l] = 0; - a->add_cooldown [l]= 0; - a->add_speed[l] = 0; - a->add_hp[l] = 0; - a->add_capacity[l] = 0; - a->upkeep[l] = 0; - } -} - -void brain_init (info_brain *a) { - strcpy(a->name, "nameless"); - for (int l=0; lupkeep[l] = 0; - } -} - +*/ void info_unit_parse (char *json, info_unit *u, jsmntok_t *t, int r, infos *info) @@ -442,284 +138,6 @@ void info_unit_parse (char *json, info_unit *u, jsmntok_t *t, int r, } } -void info_weapon_parse (char *json, info_weapon *w, jsmntok_t *t, int r, - infos *info) -{ - weapon_init(w); - int obj_i = 0, dict_i = -1; - for (int i=0; iname, t+i+1); - i++; - } - if (strcmp(key, "damage_type") == 0) { - char val[32]; substr_token(json, val, t+i+1); - w->damage_type = damage_type_map(val); - i++; - } - if (strcmp(key, "weight") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->weight, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "cooldown") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->cooldown, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "damage") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->damage, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "range") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->range, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "aoe") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->aoe, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "knockback") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->knockback, t+i+2, rt-1, 'i'); - i += rt; - } - if (strcmp(key, "damage_battery") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->damage_battery, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "stun") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->stun, t+i+2, rt-1, 'f'); - i += rt; - } - for (int h=0; h<7; h++) { - char strkey[32]; sprintf(strkey, "reduce_%s", - info->damage_types[h]); - if (strcmp(key, strkey) == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->reduce_armor[h], t+i+2, rt-1, 'f'); - i += rt; - break; - } - } - if (strcmp(key, "upkeep") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, w->upkeep, t+i+2, rt-1, 'f'); - i += rt; - } - } - } -} - -void info_chassis_parse (char *json, info_chassis *c, jsmntok_t *t, int r, - infos *info) -{ - chassis_init(c); - int obj_i = 0, dict_i = -1; - for (int i=0; iname, t+i+1); - i++; - } - if (strcmp(key, "slot_weapon") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, c->slot_weapon, t+i+2, rt-1, 'i'); - i += rt; - } - if (strcmp(key, "slot_armor") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, c->slot_armor, t+i+2, rt-1, 'i'); - i += rt; - } - if (strcmp(key, "slot_aug") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, c->slot_aug, t+i+2, rt-1, 'i'); - i += rt; - } - if (strcmp(key, "weight_max") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, c->weight_max, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "hp") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, c->hp, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "speed") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, c->speed, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "upkeep") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, c->upkeep, t+i+2, rt-1, 'f'); - i += rt; - } - } - } -} - -void info_battery_parse (char *json, info_battery *b, jsmntok_t *t, int r, - infos *info) -{ - battery_init(b); - int obj_i = 0, dict_i = -1; - for (int i=0; iname, t+i+1); - i++; - } - if (strcmp(key, "weight") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, b->weight, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "capacity") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, b->capacity, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "recharge") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, b->recharge, t+i+2, rt-1, 'i'); - i += rt; - } - } - } -} - -void info_armor_parse (char *json, info_armor *a, jsmntok_t *t, int r, - infos *info) -{ - armor_init(a); - int obj_i = 0, dict_i = -1; - for (int i=0; iname, t+i+1); - i++; - } - if (strcmp(key, "weight") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->weight, t+i+2, rt-1, 'f'); - i += rt; - } - for (int h=0; h<7; h++) { - if (strcmp(key, info->damage_types[h]) == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->armor[h], t+i+2, rt-1, 'f'); - i += rt; - } - } - if (strcmp(key, "upkeep") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->upkeep, t+i+2, rt-1, 'f'); - i += rt; - } - } - } -} - -void info_aug_parse (char *json, info_aug *a, jsmntok_t *t, int r, - infos *info) -{ - aug_init(a); - int obj_i = 0, dict_i = -1; - for (int i=0; iname, t+i+1); - i++; - } - if (strcmp(key, "weight") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->weight, t+i+2, rt-1, 'f'); - i += rt; - } - for (int h=0; h<7; h++) { - char strkey[32]; sprintf(strkey, "damage_%s", - info->damage_types[h]); - if (strcmp(key, strkey) == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->add_damage[h], t+i+2, rt-1, 'f'); - i += rt; - break; - } - } - for (int h=0; h<7; h++) { - char strkey[32]; sprintf(strkey, "armor_%s", - info->damage_types[h]); - if (strcmp(key, strkey) == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->add_armor[h], t+i+2, rt-1, 'f'); - i += rt; - break; - } - } - if (strcmp(key, "add_range") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->add_range, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "add_cooldown") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->add_cooldown, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "add_hp") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->add_hp, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "add_capacity") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->add_capacity, t+i+2, rt-1, 'f'); - i += rt; - } - if (strcmp(key, "upkeep") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->upkeep, t+i+2, rt-1, 'f'); - i += rt; - } - } - } -} - -void info_brain_parse (char *json, info_brain *a, jsmntok_t *t, int r, - infos *info) -{ - brain_init(a); - int obj_i = 0, dict_i = -1; - for (int i=0; iname, t+i+1); - i++; - } - if (strcmp(key, "upkeep") == 0) { - int rt = json_parse_subtokens(json, t, r, i+1); - json_parse_array(json, a->upkeep, t+i+2, rt-1, 'f'); - i += rt; - } - } - } -} - void info_parse_json (infos *info, char *json, char *obj) { jsmn_parser p; jsmn_init(&p); jsmntok_t t[MAXTOKENS]; @@ -733,36 +151,6 @@ void info_parse_json (infos *info, char *json, char *obj) { info->templates+index, t+i+1, rt, info); info->templateslen ++; } - if (strcmp(obj, "weapon") == 0) { - info_weapon_parse(json, - info->weapons+index, t+i+1, rt, info); - info->weaponslen ++; - } - if (strcmp(obj, "chassis") == 0) { - info_chassis_parse(json, - info->chassis+index, t+i+1, rt, info); - info->chassislen ++; - } - if (strcmp(obj, "battery") == 0) { - info_battery_parse(json, - info->batteries+index, t+i+1, rt, info); - info->batterieslen ++; - } - if (strcmp(obj, "armor") == 0) { - info_armor_parse(json, - info->armors+index, t+i+1, rt, info); - info->armorslen ++; - } - if (strcmp(obj, "aug") == 0) { - info_aug_parse(json, - info->augs+index, t+i+1, rt, info); - info->augslen ++; - } - if (strcmp(obj, "brain") == 0) { - info_brain_parse(json, - info->brains+index, t+i+1, rt, info); - info->brainslen ++; - } index ++; i += rt-1; } @@ -1189,19 +577,6 @@ void info_load (infos *info) { int size = 1024*64; char json[size]; type_damage_map(info->damage_types); - info->augslen = 0; - info_read_file(json, "content/weapons.txt", size); - info_parse_json(info, json, "weapon"); - info_read_file(json, "content/chassis.txt", size); - info_parse_json(info, json, "chassis"); - info_read_file(json, "content/batteries.txt", size); - info_parse_json(info, json, "battery"); - info_read_file(json, "content/armor.txt", size); - info_parse_json(info, json, "armor"); - info_read_file(json, "content/augments.txt", size); - info_parse_json(info, json, "aug"); - info_read_file(json, "content/brains.txt", size); - info_parse_json(info, json, "brain"); info_read_file(json, "content/templates/default.txt", size); info_parse_json(info, json, "template"); -- cgit v1.2.3-54-g00ecf