forked from github/server
eliminate MIN and MAX macros
This commit is contained in:
parent
5a01ea14b6
commit
9b113c050e
6 changed files with 40 additions and 19 deletions
|
@ -16,7 +16,10 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <platform.h>
|
#ifdef _MSC_VER
|
||||||
|
# include <platform.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "weapons.h"
|
#include "weapons.h"
|
||||||
#include "battle.h"
|
#include "battle.h"
|
||||||
|
|
||||||
|
@ -106,7 +109,7 @@ int *casualties)
|
||||||
}
|
}
|
||||||
|
|
||||||
enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE);
|
enemies = count_enemies(b, af, FIGHT_ROW, FIGHT_ROW, SELECT_ADVANCE);
|
||||||
enemies = MIN(enemies, CATAPULT_ATTACKS);
|
if (enemies > CATAPULT_ATTACKS) enemies = CATAPULT_ATTACKS;
|
||||||
if (enemies == 0) {
|
if (enemies == 0) {
|
||||||
return true; /* allow further attacks */
|
return true; /* allow further attacks */
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,10 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <platform.h>
|
#ifdef _MSC_VER
|
||||||
|
# include <platform.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "region.h"
|
#include "region.h"
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
|
@ -141,8 +144,11 @@ const char *regionname(const region * r, const faction * f)
|
||||||
int region_maxworkers(const region *r)
|
int region_maxworkers(const region *r)
|
||||||
{
|
{
|
||||||
int size = max_production(r);
|
int size = max_production(r);
|
||||||
int treespace = (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE;
|
int treespace = size - (rtrees(r, 2) + rtrees(r, 1) / 2) * TREESIZE;
|
||||||
return MAX(size - treespace, MIN(size / 10, 200));
|
size /=10;
|
||||||
|
if (size > 200) size = 200;
|
||||||
|
if (treespace < size) treespace = size;
|
||||||
|
return treespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
int deathcount(const region * r)
|
int deathcount(const region * r)
|
||||||
|
@ -400,7 +406,7 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height)
|
||||||
int dx = x1 - x2;
|
int dx = x1 - x2;
|
||||||
int dy = y1 - y2;
|
int dy = y1 - y2;
|
||||||
int result, dist;
|
int result, dist;
|
||||||
int mindist = MIN(width, height) >> 1;
|
int mindist = ((width > height) ? height : width) / 2;
|
||||||
|
|
||||||
/* Bei negativem dy am Ursprung spiegeln, das veraendert
|
/* Bei negativem dy am Ursprung spiegeln, das veraendert
|
||||||
* den Abstand nicht
|
* den Abstand nicht
|
||||||
|
@ -423,13 +429,15 @@ koor_distance_wrap_xy(int x1, int y1, int x2, int y2, int width, int height)
|
||||||
if (result <= mindist)
|
if (result <= mindist)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
dist = MAX(dx, height - dy);
|
dist = height - dy;
|
||||||
|
if (dist < dx) dist = dx;
|
||||||
if (dist >= 0 && dist < result) {
|
if (dist >= 0 && dist < result) {
|
||||||
result = dist;
|
result = dist;
|
||||||
if (result <= mindist)
|
if (result <= mindist)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
dist = MAX(width - dx, dy);
|
dist = width - dx;
|
||||||
|
if (dist < dy) dist = dy;
|
||||||
if (dist >= 0 && dist < result)
|
if (dist >= 0 && dist < result)
|
||||||
result = dist;
|
result = dist;
|
||||||
return result;
|
return result;
|
||||||
|
@ -1097,7 +1105,8 @@ void init_region(region *r)
|
||||||
if (!fval(r, RF_CHAOTIC)) {
|
if (!fval(r, RF_CHAOTIC)) {
|
||||||
int peasants;
|
int peasants;
|
||||||
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
peasants = (region_maxworkers(r) * (20 + dice(6, 10))) / 100;
|
||||||
rsetpeasants(r, MAX(100, peasants));
|
if (peasants < 100) peasants = 100;
|
||||||
|
rsetpeasants(r, peasants);
|
||||||
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
rsetmoney(r, rpeasants(r) * ((wage(r, NULL, NULL,
|
||||||
INT_MAX) + 1) + rng_int() % 5));
|
INT_MAX) + 1) + rng_int() % 5));
|
||||||
}
|
}
|
||||||
|
@ -1419,7 +1428,8 @@ faction *update_owners(region * r)
|
||||||
else if (f || new_owner->faction != region_get_last_owner(r)) {
|
else if (f || new_owner->faction != region_get_last_owner(r)) {
|
||||||
alliance *al = region_get_alliance(r);
|
alliance *al = region_get_alliance(r);
|
||||||
if (al && new_owner->faction->alliance == al) {
|
if (al && new_owner->faction->alliance == al) {
|
||||||
int morale = MAX(0, region_get_morale(r) - MORALE_TRANSFER);
|
int morale = region_get_morale(r) - MORALE_TRANSFER;
|
||||||
|
if (morale < 0) morale = 0;
|
||||||
region_set_morale(r, morale, turn);
|
region_set_morale(r, morale, turn);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -16,7 +16,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <platform.h>
|
#ifdef _MSC_VER
|
||||||
|
# include <platform.h>
|
||||||
|
#endif
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
|
|
||||||
|
@ -359,8 +361,9 @@ int shipspeed(const ship * sh, const unit * u)
|
||||||
int crew = crew_skill(sh);
|
int crew = crew_skill(sh);
|
||||||
int crew_bonus = (crew / sh->type->sumskill / 2) - 1;
|
int crew_bonus = (crew / sh->type->sumskill / 2) - 1;
|
||||||
if (crew_bonus > 0) {
|
if (crew_bonus > 0) {
|
||||||
bonus = MIN(bonus, crew_bonus);
|
int sbonus = sh->type->range_max - sh->type->range;
|
||||||
bonus = MIN(bonus, sh->type->range_max - sh->type->range);
|
if (bonus > sbonus) bonus = sbonus;
|
||||||
|
if (bonus > crew_bonus) bonus = crew_bonus;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bonus = 0;
|
bonus = 0;
|
||||||
|
|
|
@ -16,7 +16,9 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <platform.h>
|
#ifdef _MSC_VER
|
||||||
|
# include <platform.h>
|
||||||
|
#endif
|
||||||
#include <kernel/config.h>
|
#include <kernel/config.h>
|
||||||
#include "unit.h"
|
#include "unit.h"
|
||||||
|
|
||||||
|
@ -1229,7 +1231,7 @@ int invisible(const unit * target, const unit * viewer)
|
||||||
else {
|
else {
|
||||||
int hidden = item_invis(target);
|
int hidden = item_invis(target);
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
hidden = MIN(hidden, target->number);
|
if (hidden > target->number) hidden = target->number;
|
||||||
if (viewer) {
|
if (viewer) {
|
||||||
const resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING);
|
const resource_type *rtype = get_resourcetype(R_AMULET_OF_TRUE_SEEING);
|
||||||
hidden -= i_get(viewer->items, rtype->itype);
|
hidden -= i_get(viewer->items, rtype->itype);
|
||||||
|
|
|
@ -4089,7 +4089,7 @@ static int sp_pump(castorder * co)
|
||||||
* Betoert eine Einheit, so das sie ihm den groe<EFBFBD>ten Teil ihres Bargelds
|
* Betoert eine Einheit, so das sie ihm den groe<EFBFBD>ten Teil ihres Bargelds
|
||||||
* und 50% ihres Besitzes schenkt. Sie behaelt jedoch immer soviel, wie
|
* und 50% ihres Besitzes schenkt. Sie behaelt jedoch immer soviel, wie
|
||||||
* sie zum ueberleben braucht. Wirkt gegen Magieresistenz.
|
* sie zum ueberleben braucht. Wirkt gegen Magieresistenz.
|
||||||
* MIN(Stufe*1000$, u->money - maintenance)
|
* min(Stufe*1000$, u->money - maintenance)
|
||||||
* Von jedem Item wird 50% abgerundet ermittelt und uebergeben. Dazu
|
* Von jedem Item wird 50% abgerundet ermittelt und uebergeben. Dazu
|
||||||
* kommt Itemzahl%2 mit 50% chance
|
* kommt Itemzahl%2 mit 50% chance
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,7 +16,10 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <platform.h>
|
#ifdef _MSC_VER
|
||||||
|
# include <platform.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "shock.h"
|
#include "shock.h"
|
||||||
|
|
||||||
#include <magic.h>
|
#include <magic.h>
|
||||||
|
@ -61,8 +64,8 @@ static void do_shock(unit * u, const char *reason)
|
||||||
if (u->number > 0) {
|
if (u->number > 0) {
|
||||||
/* HP - Verlust */
|
/* HP - Verlust */
|
||||||
int hp = (unit_max_hp(u) * u->number) / 10;
|
int hp = (unit_max_hp(u) * u->number) / 10;
|
||||||
hp = MIN(u->hp, hp);
|
if (hp > u->hp) hp = u->hp;
|
||||||
u->hp = MAX(1, hp);
|
u->hp = (hp > 1) ? hp : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Aura - Verlust */
|
/* Aura - Verlust */
|
||||||
|
|
Loading…
Reference in a new issue