Skip to content

Commit

Permalink
Merge git://github.com/kevingranade/Cataclysm
Browse files Browse the repository at this point in the history
Conflicts:
	player.cpp
  • Loading branch information
TheDarklingWolf committed Jan 13, 2013
2 parents dafe823 + 0f39a18 commit 8d5be56
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 22 deletions.
8 changes: 8 additions & 0 deletions crafting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,14 @@ RECIPE(itm_c4, CC_WEAPON, sk_mechanics, sk_electronics, 4, 8000);
TOOL(itm_rock, -1, itm_toolset, -1, NULL);
COMP(itm_apple, 3, NULL);

RECIPE(itm_long_island, CC_FOOD, sk_cooking, sk_null, 1, 7000, false);
COMP(itm_cola, 1, NULL);
COMP(itm_vodka, 1, NULL);
COMP(itm_gin, 1, NULL);
COMP(itm_rum, 1, NULL);
COMP(itm_tequila, 1, NULL);
COMP(itm_triple_sec, 1, NULL);

RECIPE(itm_jerky, CC_FOOD, sk_cooking, sk_null, 3, 30000, false);
TOOL(itm_hotplate, 10, itm_toolset, 5, itm_fire, -1, NULL);
COMP(itm_salt_water, 1, itm_salt, 4, NULL);
Expand Down
48 changes: 28 additions & 20 deletions item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ int item::pick_reload_ammo(player &u, bool interactive)
(has_spare_mag != -1 && contents[has_spare_mag].charges < tmp->clip)) {
std::vector<int> tmpammo = u.has_ammo(ammo_type());
for (int i = 0; i < tmpammo.size(); i++)
if (charges >= 0 || u.inv[tmpammo[i]].typeId() == curammo->id)
if (charges <= 0 || u.inv[tmpammo[i]].typeId() == curammo->id)
am.push_back(tmpammo[i]);
}

Expand All @@ -1516,7 +1516,7 @@ int item::pick_reload_ammo(player &u, bool interactive)
contents[i].charges < (dynamic_cast<it_gunmod*>(contents[i].type))->clip) {
std::vector<int> tmpammo = u.has_ammo((dynamic_cast<it_gunmod*>(contents[i].type))->newtype);
for(int j = 0; j < tmpammo.size(); j++)
if (contents[i].charges >= 0 ||
if (contents[i].charges <= 0 ||
u.inv[tmpammo[j]].typeId() == contents[i].curammo->id)
am.push_back(tmpammo[j]);
}
Expand Down Expand Up @@ -1568,6 +1568,11 @@ bool item::reload(player &u, int index)
bool single_load = false;
int max_load = 1;
item *reload_target = NULL;
item *ammo_to_use = &u.inv[index];

// Handle ammo in containers, currently only gasoline
if(ammo_to_use->is_container())
ammo_to_use = &ammo_to_use->contents[0];

if (is_gun()) {
// Reload using a spare magazine
Expand All @@ -1584,27 +1589,27 @@ bool item::reload(player &u, int index)
// Determine what we're reloading, the gun, a spare magazine, or another gunmod.
// Prefer the active gunmod if there is one
item* gunmod = active_gunmod();
if (gunmod != NULL && gunmod->ammo_type() == u.inv[index].ammo_type() &&
(gunmod->charges <= 0 || gunmod->curammo->id == u.inv[index].typeId())) {
if (gunmod != NULL && gunmod->ammo_type() == ammo_to_use->ammo_type() &&
(gunmod->charges <= 0 || gunmod->curammo->id == ammo_to_use->typeId())) {
reload_target = gunmod;
// Then prefer the gun itself
} else if (charges < clip_size() &&
ammo_type() == u.inv[index].ammo_type() &&
(charges <= 0 || curammo->id == u.inv[index].typeId())) {
ammo_type() == ammo_to_use->ammo_type() &&
(charges <= 0 || curammo->id == ammo_to_use->typeId())) {
reload_target = this;
// Then prefer a spare mag if present
} else if (spare_mag != -1 &&
ammo_type() == u.inv[index].ammo_type() &&
ammo_type() == ammo_to_use->ammo_type() &&
contents[spare_mag].charges != (dynamic_cast<it_gun*>(type))->clip &&
(charges <= 0 || curammo->id == u.inv[index].typeId())) {
(charges <= 0 || curammo->id == ammo_to_use->typeId())) {
reload_target = &contents[spare_mag];
// Finally consider other gunmods
} else {
for (int i = 0; i < contents.size(); i++) {
if (&contents[i] != gunmod && i != spare_mag && contents[i].is_gunmod() &&
contents[i].has_flag(IF_MODE_AUX) && contents[i].ammo_type() == u.inv[index].ammo_type() &&
contents[i].has_flag(IF_MODE_AUX) && contents[i].ammo_type() == ammo_to_use->ammo_type() &&
(contents[i].charges <= (dynamic_cast<it_gunmod*>(contents[i].type))->clip ||
(contents[i].charges <= 0 || contents[i].curammo->id == u.inv[index].typeId()))) {
(contents[i].charges <= 0 || contents[i].curammo->id == ammo_to_use->typeId()))) {
reload_target = &contents[i];
break;
}
Expand Down Expand Up @@ -1636,30 +1641,33 @@ bool item::reload(player &u, int index)
// If the gun is currently loaded with a different type of ammo, reloading fails
if ((reload_target->is_gun() || reload_target->is_gunmod()) &&
reload_target->charges > 0 &&
reload_target->curammo->id != u.inv[index].typeId())
reload_target->curammo->id != ammo_to_use->typeId())
return false;
if (reload_target->is_gun() || reload_target->is_gunmod()) {
if (!u.inv[index].is_ammo()) {
if (!ammo_to_use->is_ammo()) {
debugmsg("Tried to reload %s with %s!", tname().c_str(),
u.inv[index].tname().c_str());
ammo_to_use->tname().c_str());
return false;
}
reload_target->curammo = dynamic_cast<it_ammo*>((u.inv[index].type));
reload_target->curammo = dynamic_cast<it_ammo*>((ammo_to_use->type));
}
if (single_load || max_load == 1) { // Only insert one cartridge!
reload_target->charges++;
u.inv[index].charges--;
ammo_to_use->charges--;
} else {
reload_target->charges += u.inv[index].charges;
u.inv[index].charges = 0;
reload_target->charges += ammo_to_use->charges;
ammo_to_use->charges = 0;
if (reload_target->charges > max_load) {
// More rounds than the clip holds, put some back
u.inv[index].charges += reload_target->charges - max_load;
ammo_to_use->charges += reload_target->charges - max_load;
reload_target->charges = max_load;
}
}
if (u.inv[index].charges == 0)
u.i_remn(index);
if (ammo_to_use->charges == 0)
if (u.inv[index].is_container())
u.inv[index].contents.erase(u.inv[index].contents.begin());
else
u.i_remn(index);
return true;
} else
return false;
Expand Down
3 changes: 2 additions & 1 deletion itype.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ itm_fire, itm_toolset, itm_apparatus,
// Drinks
itm_water, itm_water_clean, itm_sewage, itm_salt_water, itm_oj, itm_apple_cider,
itm_energy_drink, itm_cola, itm_rootbeer, itm_milk, itm_V8, itm_broth,
itm_soup, itm_whiskey, itm_vodka, itm_rum, itm_tequila, itm_beer, itm_bleach,
itm_soup, itm_whiskey, itm_vodka, itm_gin, itm_rum, itm_tequila, itm_triple_sec,
itm_long_island, itm_beer, itm_bleach,
itm_ammonia, itm_mutagen, itm_purifier, itm_tea, itm_coffee, itm_blood,
// Monster Meats
itm_meat, itm_veggy, itm_meat_tainted, itm_veggy_tainted, itm_meat_cooked,
Expand Down
13 changes: 13 additions & 0 deletions itypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ DRINK("vodka", 20, 78, c_ltcyan, itm_bottle_glass,
-10, 2, 0,-12, -2, 5, 7, 15,&iuse::alcohol, ADD_ALCOHOL, "\
In Soviet Russia, vodka drinks you!");

DRINK("gin", 20, 78, c_ltcyan, itm_bottle_glass,
-10, 2, 0,-12, -2, 5, 7, 15,&iuse::alcohol, ADD_ALCOHOL, "\
Smells faintly of elderberries, but mostly booze.");

DRINK("rum", 14, 85, c_ltcyan, itm_bottle_glass,
-12, 2, 0,-10, -2, 5, 7, 15,&iuse::alcohol, ADD_ALCOHOL, "\
Drinking this might make you feel like a pirate. Or not.");
Expand All @@ -139,6 +143,15 @@ DRINK("tequila", 12, 88, c_brown, itm_bottle_glass,
-12, 2, 0,-12, -2, 6, 7, 18,&iuse::alcohol, ADD_ALCOHOL, "\
Don't eat the worm! Wait, there's no worm in this bottle.");

DRINK("triple sec", 12, 55, c_brown, itm_bottle_glass,
-8, 2, 0,-10, -2, 4, 7, 10,&iuse::alcohol, ADD_ALCOHOL, "\
An orange flavored liquor used in many mixed drinks.");

DRINK("long island iced tea", 8, 100, c_brown, itm_bottle_glass,
-10, 2, 0,-10, -2, 5, 6, 20,&iuse::alcohol, ADD_ALCOHOL, "\
A blend of incredibly strong-flavored liquors that somehow tastes\n\
like none of them.");

DRINK("beer", 60, 35, c_brown, itm_can_drink,
16, 4, 0, -4, -1, 2, 1, 10, &iuse::alcohol, ADD_ALCOHOL, "\
Best served cold, in a glass, and with a lime - but you're not that lucky.");
Expand Down
2 changes: 1 addition & 1 deletion mapitemsdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ void game::init_mapitems()

setvector(
mapitems[mi_alcohol],
itm_whiskey, itm_vodka, itm_rum, itm_tequila, NULL);
itm_whiskey, itm_vodka, itm_gin, itm_rum, itm_tequila, itm_triple_sec, NULL);

setvector(
mapitems[mi_pool_table],
Expand Down
6 changes: 6 additions & 0 deletions player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4903,6 +4903,12 @@ std::vector<int> player::has_ammo(ammotype at)
}
if (newtype)
ret.push_back(a);
// Handle gasoline nested in containers
} else if (at == AT_GAS && inv[a].is_container() &&
!inv[a].contents.empty() && inv[a].contents[0].is_ammo() &&
dynamic_cast<it_ammo*>(inv[a].contents[0].type)->type == at) {
ret.push_back(a);
return ret;
}
}
return ret;
Expand Down

0 comments on commit 8d5be56

Please sign in to comment.