Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Northfear committed Aug 8, 2020
2 parents dd9d586 + d0da834 commit f7ccc48
Show file tree
Hide file tree
Showing 19 changed files with 68 additions and 57 deletions.
9 changes: 6 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
GemRB git (052986b):
GemRB git (a318ab21):
New features:
-
- new smarter pathfinder with bumping support
- full morale support
- animal taming, iwd2 hardcoded saving throw bonuses
- vcpkg and out-of-the box msvc support
- non-ascii data filename support

Improved features:
-
- windows speedups, ease of setup
- iwd chargen, pst spell timing
- disk reading speedups, ease of setup
- iwd chargen, pst spell timing, hardcoded overlays
- better actor speeds & walk sounds
- audio, pst ini handling, savegame compatibility
- effects, projectiles, actions, range calculations
- bugfixes
Expand Down
3 changes: 1 addition & 2 deletions gemrb/core/Calendar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ namespace GemRB {

Calendar::Calendar(void)
{
int i;
daysinyear = 0;
AutoTable tab("months");
if (!tab) {
Expand All @@ -42,7 +41,7 @@ Calendar::Calendar(void)
monthnamecount = tab->GetRowCount();
monthnames = (int *) malloc(sizeof(int) * monthnamecount);
days = (int *) malloc(sizeof(int) * monthnamecount);
for(i=0;i<monthnamecount;i++) {
for (int i = 0; i < monthnamecount; i++) {
days[i]=atoi(tab->QueryField(i,0));
daysinyear+=days[i];
monthnames[i]=atoi(tab->QueryField(i,1));
Expand Down
22 changes: 10 additions & 12 deletions gemrb/core/CharAnimations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,12 @@ void CharAnimations::SetupColors(PaletteType type)
return;
}

int i;
bool needmod = false;
if (GlobalColorMod.type != RGBModifier::NONE) {
needmod = true;
} else {
for (i = 0; i < 7; ++i) {
// TODO: should that -1 really be there??
for (size_t i = 0; i < PAL_MAX - 1; ++i) {
if (ColorMods[i+8*type].type != RGBModifier::NONE)
needmod = true;
}
Expand Down Expand Up @@ -668,8 +668,7 @@ void CharAnimations::InitAvatarsTable()
CharAnimations::CharAnimations(unsigned int AnimID, ieDword ArmourLevel)
{
Colors = NULL;
int i,j;
for (i = 0; i < PAL_MAX; ++i) {
for (size_t i = 0; i < PAL_MAX; ++i) {
change[i] = true;
modifiedPalette[i] = NULL;
palette[i] = NULL;
Expand All @@ -683,22 +682,22 @@ CharAnimations::CharAnimations(unsigned int AnimID, ieDword ArmourLevel)
InitAvatarsTable();
}

for (i = 0; i < MAX_ANIMS; i++) {
for (j = 0; j < MAX_ORIENT; j++) {
for (size_t i = 0; i < MAX_ANIMS; i++) {
for (size_t j = 0; j < MAX_ORIENT; j++) {
Anims[i][j] = NULL;
shadowAnimations[i][j] = NULL;
}
}
ArmorType = 0;
RangedType = 0;
WeaponType = 0;
for (i = 0; i < 5; ++i) {
for (size_t i = 0; i < 5; ++i) {
PaletteResRef[i][0] = 0;
}
WeaponRef[0] = 0;
HelmetRef[0] = 0;
OffhandRef[0] = 0;
for (i = 0; i < PAL_MAX * 8; ++i) {
for (size_t i = 0; i < PAL_MAX * 8; ++i) {
ColorMods[i].type = RGBModifier::NONE;
ColorMods[i].speed = 0;
// make initial phase depend on location to make the pulse appear
Expand Down Expand Up @@ -2880,7 +2879,6 @@ void CharAnimations::AddHLSuffix(char* ResRef, unsigned char StanceID,
void CharAnimations::PulseRGBModifiers()
{
unsigned long time = core->GetGame()->Ticks;
int i;

if (time - lastModUpdate <= 40)
return;
Expand All @@ -2893,7 +2891,7 @@ void CharAnimations::PulseRGBModifiers()
GlobalColorMod.speed > 0)
{
GlobalColorMod.phase += inc;
for (i = 0; i < PAL_MAX; ++i) {
for (size_t i = 0; i < PAL_MAX; ++i) {
change[i] = true;
}

Expand All @@ -2906,7 +2904,7 @@ void CharAnimations::PulseRGBModifiers()
}
}

for (i = 0; i < PAL_MAX * 8; ++i) {
for (size_t i = 0; i < PAL_MAX * 8; ++i) {
if (ColorMods[i].type != RGBModifier::NONE &&
ColorMods[i].speed > 0)
{
Expand All @@ -2921,7 +2919,7 @@ void CharAnimations::PulseRGBModifiers()
}
}

for (i = 0; i < PAL_MAX; ++i) {
for (size_t i = 0; i < PAL_MAX; ++i) {
if (change[i]) {
change[i] = false;
SetupColors((PaletteType) i);
Expand Down
5 changes: 2 additions & 3 deletions gemrb/core/Dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,16 @@ int Dialog::FindFirstState(Scriptable* target)

int Dialog::FindRandomState(Scriptable* target)
{
unsigned int i;
unsigned int max = TopLevelCount;
if (!max) return -1;
unsigned int pick = RAND(0, max-1);
for (i=pick; i < max; i++) {
for (unsigned int i = pick; i < max; i++) {
Condition *cond = GetState(i)->condition;
if (cond && cond->Evaluate(target)) {
return i;
}
}
for (i=0; i < pick; i++) {
for (unsigned int i = 0; i < pick; i++) {
Condition *cond = GetState(i)->condition;
if (cond && cond->Evaluate(target)) {
return i;
Expand Down
10 changes: 3 additions & 7 deletions gemrb/core/EffectQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,14 @@ static inline void ResolveEffectRef(EffectRef &effect_reference)

bool Init_EffectQueue()
{
int i;

if( initialized) {
return true;
}
pstflags = !!core->HasFeature(GF_PST_STATE_FLAGS);
iwd2fx = !!core->HasFeature(GF_ENHANCED_EFFECTS);

memset( Opcodes, 0, sizeof( Opcodes ) );
for(i=0;i<MAX_EFFECTS;i++) {
for (size_t i = 0; i < MAX_EFFECTS; i++) {
Opcodes[i].Strref=-1;
}

Expand All @@ -286,7 +284,7 @@ bool Init_EffectQueue()
return false;
}

for (i = 0; i < MAX_EFFECTS; i++) {
for (unsigned int i = 0; i < MAX_EFFECTS; i++) {
const char* effectname = effectsTable->GetValue( i );
if( efftextTable) {
int row = efftextTable->GetRowCount();
Expand All @@ -311,7 +309,6 @@ bool Init_EffectQueue()
}
poi->opcode = i;
}
//print("-------- FN: %d, %s", i, effectname);
}
core->DelSymbol( eT );

Expand Down Expand Up @@ -1019,7 +1016,7 @@ static int check_type(Actor* actor, const Effect* fx)

//level decrementing bounce check
if (fx->Power) {
if( (bounce&BNC_LEVEL_DEC)) {
if (bounce & BNC_LEVEL_DEC) {
efx=actor->fxqueue.HasEffectWithParamPair(fx_level_bounce_dec_ref, 0, fx->Power);
if( efx) {
if (DecreaseEffect(efx)) {
Expand Down Expand Up @@ -1221,7 +1218,6 @@ static bool check_resistance(Actor* actor, Effect* fx)

int EffectQueue::ApplyEffect(Actor* target, Effect* fx, ieDword first_apply, ieDword resistance) const
{
//print("FX 0x%02x: %s(%d, %d)", fx->Opcode, effectnames[fx->Opcode].Name, fx->Parameter1, fx->Parameter2);
if (fx->TimingMode == FX_DURATION_JUST_EXPIRED) {
return FX_NOT_APPLIED;
}
Expand Down
5 changes: 0 additions & 5 deletions gemrb/core/EffectQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ class GEM_EXPORT EffectQueue {
Effect *HasEffectWithSource(EffectRef &effect_reference, const ieResRef source) const;
void DecreaseParam1OfEffect(EffectRef &effect_reference, ieDword amount) const;
int DecreaseParam3OfEffect(EffectRef &effect_reference, ieDword amount, ieDword param2) const;
//int SpecificDamageBonus(ieDword damage_type) const;
int BonusForParam2(EffectRef &effect_reference, ieDword param2) const;
int MaxParam1(EffectRef &effect_reference, bool positive) const;
bool HasAnyDispellableEffect() const;
Expand All @@ -294,10 +293,6 @@ class GEM_EXPORT EffectQueue {
int SumDamageReduction(EffectRef &effect_reference, ieDword weaponEnchantment, int &total) const;
//melee and ranged effects
void AddWeaponEffects(EffectQueue *fxqueue, EffectRef &fx_ref) const;
// checks if spells of type "types" are disabled (usually by armor)
// returns a bitfield of disabled spelltypes
// it is no longer used
//int DisabledSpellcasting(int types) const;

// returns -1 if bounced, 0 if resisted, 1 if accepted spell
int CheckImmunity(Actor *target) const;
Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/GUI/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Control* Window::GetControl(unsigned short x, unsigned short y, bool ignore)
Control* ctrl = NULL;

//Check if we are still on the last control
if (( lastC != NULL )) {
if (lastC) {
if (( XPos + lastC->XPos <= x )
&& ( YPos + lastC->YPos <= y )
&& ( XPos + lastC->XPos + lastC->Width >= x )
Expand Down
5 changes: 2 additions & 3 deletions gemrb/core/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,10 @@ Game::Game(void) : Scriptable( ST_GLOBAL )
if (table.load(tn)) {
int cols = table->GetColumnCount();
int rows = table->GetRowCount();
int i, j;
npclevels.reserve(rows);
for (i = 0; i < rows; i++) {
for (int i = 0; i < rows; i++) {
npclevels.push_back (std::vector<char *>(cols+1));
for(j = -1; j < cols; j++) {
for (int j = -1; j < cols; j++) {
char *ref = new char[9];
if (j == -1) {
CopyResRef(ref, table->GetRowName(i));
Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/IniSpawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void IniSpawn::RespawnNameless()
strnuprcpy(NamelessSpawnArea, nameless->Area, 8);
}

nameless->Resurrect();
nameless->Resurrect(NamelessSpawnPoint);
// resurrect leaves you at 1hp for raise dead, so manually bump it back to max
nameless->RefreshEffects(NULL);
nameless->SetBase(IE_HITPOINTS, 9999);
Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5506,7 +5506,7 @@ bool Interface::Autopause(ieDword flag, Scriptable* target)
ieDword autopause_flags = 0;
vars->Lookup("Auto Pause State", autopause_flags);

if ((autopause_flags & (1<<flag))) {
if (autopause_flags & (1<<flag)) {
if (SetPause(PAUSE_ON, PF_QUIET)) {
displaymsg->DisplayConstantString(STR_AP_UNUSABLE+flag, DMC_RED);

Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/Map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3471,7 +3471,7 @@ void AreaAnimation::Draw(const Region &screen, Map *area)
//transparency
ieByte inverseTransparency = 255-transparency;
Color tint = {255,255,255,inverseTransparency};
if ((Flags&A_ANI_NO_SHADOW)) {
if (Flags & A_ANI_NO_SHADOW) {
tint = area->LightMap->GetPixel( Pos.x / 16, Pos.y / 12);
tint.a = inverseTransparency;
}
Expand Down
26 changes: 19 additions & 7 deletions gemrb/core/Scriptable/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ static ieByte featmax[MAX_FEATS]={0
};

//holds the wspecial table for weapon prof bonuses
#define WSPECIAL_COLS 3
static int wspecial_max = 0;
static int wspattack_rows = 0;
static int wspattack_cols = 0;
Expand Down Expand Up @@ -2486,7 +2485,7 @@ static void InitActorTables()
wspecial = (int **) calloc(wspecial_max+1, sizeof(int *));

for (i=0; i<=wspecial_max; i++) {
wspecial[i] = (int *) calloc(WSPECIAL_COLS, sizeof(int));
wspecial[i] = (int *) calloc(cols, sizeof(int));
for (int j=0; j<cols; j++) {
wspecial[i][j] = atoi(tm->QueryField(i, j));
}
Expand Down Expand Up @@ -4733,10 +4732,15 @@ int Actor::Damage(int damage, int damagetype, Scriptable *hitter, int modtype, i

if (damage > 0) {
// instant chunky death if the actor is petrified or frozen
if (Modified[IE_STATE_ID] & (STATE_FROZEN|STATE_PETRIFIED) && !Modified[IE_DISABLECHUNKING] && (GameDifficulty > DIFF_NORMAL) ) {
bool allowChunking = !Modified[IE_DISABLECHUNKING] && GameDifficulty > DIFF_NORMAL;
if (Modified[IE_STATE_ID] & (STATE_FROZEN|STATE_PETRIFIED) && allowChunking) {
damage = 123456; // arbitrarily high for death; won't be displayed
LastDamageType |= DAMAGE_CHUNKING;
}
// chunky death when you're reduced below -10 hp
if ((ieDword) damage >= Modified[IE_HITPOINTS] + 10 && allowChunking) {
LastDamageType |= DAMAGE_CHUNKING;
}
// mark LastHitter for repeating damage effects (eg. to get xp from melfing trolls)
if (act && LastHitter == 0) {
LastHitter = act->GetGlobalID();
Expand Down Expand Up @@ -5198,6 +5202,7 @@ void Actor::SetMap(Map *map)
int slottype = core->QuerySlotEffects( Slot );
switch (slottype) {
case SLOT_EFFECT_NONE:
case SLOT_EFFECT_FIST:
case SLOT_EFFECT_MELEE:
case SLOT_EFFECT_MISSILE:
break;
Expand Down Expand Up @@ -5474,8 +5479,7 @@ void Actor::Turn(Scriptable *cleric, ieDword turnlevel)
}
}

//TODO: needs a way to respawn at a point
void Actor::Resurrect()
void Actor::Resurrect(const Point &destPoint)
{
if (!(Modified[IE_STATE_ID ] & STATE_DEAD)) {
return;
Expand All @@ -5484,6 +5488,10 @@ void Actor::Resurrect()
InternalFlags|=IF_ACTIVE|IF_VISIBLE; //set these flags
SetBaseBit(IE_STATE_ID, STATE_DEAD, false);
SetBase(IE_STATE_ID, 0);
SetBase(IE_AVATARREMOVAL, 0);
if (!destPoint.isnull()) {
SetPosition(destPoint, CC_CHECK_IMPASSABLE, 0);
}
if (ShouldModifyMorale()) SetBase(IE_MORALE, 10);
//resurrect spell sets the hitpoints to maximum in a separate effect
//raise dead leaves it at 1 hp
Expand Down Expand Up @@ -5964,7 +5972,11 @@ bool Actor::CheckOnDeath()
if (disintegrated) return true;

// party actors are never removed
if (Persistent()) return false;
if (Persistent()) {
// hide the corpse artificially
SetBase(IE_AVATARREMOVAL, 1);
return false;
}

//TODO: verify removal times
ieDword time = core->GetGame()->GameTime;
Expand Down Expand Up @@ -7917,7 +7929,7 @@ void Actor::UpdateActorState(ieDword gameTime) {
if (BaseStats[IE_CHECKFORBERSERK]) {
BaseStats[IE_CHECKFORBERSERK]--;
}
if ((state&STATE_CONFUSED)) {
if (state & STATE_CONFUSED) {
const char* actionString = NULL;
int tmp = core->Roll(1,3,0);
switch (tmp) {
Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/Scriptable/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ class GEM_EXPORT Actor : public Movable {
/* assigns actor to party slot, 0 = NPC, areas won't remove it */
void SetPersistent(int partyslot);
/* resurrects actor */
void Resurrect();
void Resurrect(const Point &destPoint);
/* removes actor in the next update cycle */
void DestroySelf();
/* schedules actor to die */
Expand Down
2 changes: 1 addition & 1 deletion gemrb/core/VEFObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ bool VEFObject::Draw(const Region &screen, Point &position, const Color &p_tint,
if ( (*iter).start>GameTime) continue;
if ( (*iter).length<GameTime) continue;

Point pos = ((*iter).offset);
Point pos = (*iter).offset;
pos.x+=position.x;
pos.y+=position.y;

Expand Down
1 change: 0 additions & 1 deletion gemrb/plugins/AREImporter/AREImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,6 @@ Map* AREImporter::GetMap(const char *ResRef, bool day_or_night)
}
ab->SetOrientation( Orientation,0 );
ab->TalkCount = TalkCount;
// TODO: remove corpse at removal time?
ab->RemovalTime = RemovalTime;
ab->RefreshEffects(NULL);
}
Expand Down
Loading

0 comments on commit f7ccc48

Please # to comment.