Skip to content

Commit

Permalink
(ready) minor adjustments, additions and fixes (#489)
Browse files Browse the repository at this point in the history
* Minor adjustments copied from crafting branch:
- GetFullFilename() at save.h
- v2() now grantedly initializes as 0,0
- festring bugTrackInvalidChars() in dbgmsg mode only
- better FPS positioning
- game::IsQuestItem() to avoid coded multiplicity
- new option IsAllWeightIsRelevant() to prevent item stacking with different weights
- new option IsShowVolume() for items in cm3
- item.h AddContainerPostFix() to let know how full a container is
- materials.h GetSpoilCounter() CalcNewSpoilLevel() to avoid coded multiplicity
- traps.h GetRemoveTrapModifier() TryToTearDown() for reusing outside this class
- offer to gods now remember position to help on doing it many times
- wishing now remembers previously typed
- better eclipse syntax highlight helper
- DBGBREAKPOINT

* auto merge... oops

* wizard autoplay: expectedly fixed getting route target stuck on OLTerrain where the player cant move.

* magic mushroom max active AI now extended to carnivorous plants too

* wiz autoplay: improved praying conditions;

* wiz autoplay: WIP improving praying conditions;

* wiz autoplay: improved praying conditions;
  • Loading branch information
AquariusPower authored and ryfactor committed Nov 25, 2018
1 parent 26425bd commit 13fd482
Show file tree
Hide file tree
Showing 36 changed files with 337 additions and 174 deletions.
6 changes: 5 additions & 1 deletion .devsPrefs/AquariusPower/.cproject
Expand Up @@ -152,6 +152,9 @@
<listOptionValue builtIn="false" value="XBRZLIB_RELATIVEPATHSDL"/>
<listOptionValue builtIn="false" value="XBRZLIB_NOINLINEGETSETPIX"/>
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="ECLIPSE_IDE"/>
<listOptionValue builtIn="false" value="DATADIR=/usr/local/share"/>
<listOptionValue builtIn="false" value="LOCAL_STATE_DIR=/var/lib/ivan"/>
</option>
<option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.1679517968" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" useByScannerDiscovery="false" valueType="enumerated"/>
<option id="gnu.c.compiler.option.debugging.level.843749153" name="Debug Level" superClass="gnu.c.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.c.debugging.level.max" valueType="enumerated"/>
Expand Down Expand Up @@ -179,6 +182,7 @@
<listOptionValue builtIn="false" value="XBRZLIB_RELATIVEPATHSDL"/>
<listOptionValue builtIn="false" value="XBRZLIB_NOINLINEGETSETPIX"/>
<listOptionValue builtIn="false" value="NDEBUG"/>
<listOptionValue builtIn="false" value="ECLIPSE_IDE"/>
</option>
<option id="gnu.cpp.compiler.option.optimization.level.1077402583" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.debugging.level.238683031" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
Expand Down Expand Up @@ -218,7 +222,7 @@
</toolChain>
</folderInfo>
<sourceEntries>
<entry excluding="SDL2-2.0.4|craigsapp-midifile-462f55a|rtmidi-2.1.1|portmidi|SDL2_mixer-2.0.1|demos|mihail|igor|Main/Source/wterras.cpp|Main/Source/wterra.cpp|Main/Source/wsquare.cpp|Main/Source/worldmap.cpp|Main/Source/traps.cpp|Main/Source/trap.cpp|Main/Source/terra.cpp|Main/Source/team.cpp|Main/Source/stack.cpp|Main/Source/square.cpp|Main/Source/smoke.cpp|Main/Source/slot.cpp|Main/Source/rooms.cpp|Main/Source/room.cpp|Main/Source/rain.cpp|Main/Source/proto.cpp|Main/Source/pool.cpp|Main/Source/nonhuman.cpp|Main/Source/miscitem.cpp|Main/Source/materias.cpp|Main/Source/materia.cpp|Main/Source/lterras.cpp|Main/Source/lterra.cpp|Main/Source/lsquare.cpp|Main/Source/level.cpp|Main/Source/human.cpp|Main/Source/gods.cpp|Main/Source/god.cpp|Main/Source/gear.cpp|Main/Source/fluid.cpp|Main/Source/entity.cpp|Main/Source/database.cpp|Main/Source/cont.cpp|Main/Source/char.cpp|Main/Source/bodypart.cpp|Main/Source/area.cpp|Main/Source/actions.cpp|Main/Source/item.cpp|Main/Source/action.cpp|SDL2-2.0.4/test" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
<entry excluding="Main/Source/cmdswapweap.cpp|SDL2-2.0.4|craigsapp-midifile-462f55a|rtmidi-2.1.1|portmidi|SDL2_mixer-2.0.1|demos|mihail|igor|Main/Source/wterras.cpp|Main/Source/wterra.cpp|Main/Source/wsquare.cpp|Main/Source/worldmap.cpp|Main/Source/traps.cpp|Main/Source/trap.cpp|Main/Source/terra.cpp|Main/Source/team.cpp|Main/Source/stack.cpp|Main/Source/square.cpp|Main/Source/smoke.cpp|Main/Source/slot.cpp|Main/Source/rooms.cpp|Main/Source/room.cpp|Main/Source/rain.cpp|Main/Source/proto.cpp|Main/Source/pool.cpp|Main/Source/nonhuman.cpp|Main/Source/miscitem.cpp|Main/Source/materias.cpp|Main/Source/materia.cpp|Main/Source/lterras.cpp|Main/Source/lterra.cpp|Main/Source/lsquare.cpp|Main/Source/level.cpp|Main/Source/human.cpp|Main/Source/gods.cpp|Main/Source/god.cpp|Main/Source/gear.cpp|Main/Source/fluid.cpp|Main/Source/entity.cpp|Main/Source/database.cpp|Main/Source/cont.cpp|Main/Source/char.cpp|Main/Source/bodypart.cpp|Main/Source/area.cpp|Main/Source/actions.cpp|Main/Source/item.cpp|Main/Source/action.cpp|SDL2-2.0.4/test" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
</sourceEntries>
</configuration>
</storageModule>
Expand Down
11 changes: 11 additions & 0 deletions FeLib/Include/dbgmsgproj.h
Expand Up @@ -11,6 +11,16 @@

#ifdef DBGMSG

#ifdef ECLIPSE_IDE
#define __V2_H__
#define __BITMAP_H__
#define __GRAPHICS_H__
#define __CHAR_H__
#define __ITEM_H__
#define __ERROR_H__
#define DBGMSG_STRETCHREGION
#endif

#include "dbgmsg.h"

/********************************************************************************************
Expand Down Expand Up @@ -93,6 +103,7 @@
#define DBG9(a,b,c,d,e,f,g,h,i)
#define DBGLN
#define DBGSTK
#define DBGBREAKPOINT
#define DBGTOSTR_(str)
#define DBGTOSTR(str)
#define DBGB(B)
Expand Down
2 changes: 2 additions & 0 deletions FeLib/Include/save.h
Expand Up @@ -50,6 +50,7 @@ class outputfile
void Close();
~outputfile(){Close();}
static void SetSafeSaving(truth b);
festring GetFullFilename(){return FileName;}
private:
static truth bakcupBeforeSaving;
static truth saveOnNewFileAlways;
Expand Down Expand Up @@ -81,6 +82,7 @@ class inputfile
ulong TellLineOfPos(long);
cfestring& GetFileName() const { return FileName; }
void Close() { File.close(); }
festring GetFullFilename(){return FileName;}
private:
festring ReadNumberIntr (int CallLevel, long *num, truth *isString, truth allowStr, truth PreserveTerminator);
int HandlePunct(festring&, int, int);
Expand Down
12 changes: 11 additions & 1 deletion FeLib/Include/v2.h
Expand Up @@ -29,7 +29,17 @@ struct packv2

struct v2
{
v2() = default;
/**
* TODO
* Is there some reason to NOT initialize X and Y ???
* what 'default' does that is really important/useful/necessary/required?
* as 'default' is not setting'em to 0, it is probably not good enough tho.
*
* PS.: regex to find all possible problematic places w/o this new constructor: "v2 [^=(:]*;"
* where non-initialized v2 could cause trouble.
*/
v2() : X(0), Y(0) { }; //was: v2() = default;

v2(int X, int Y) : X(X), Y(Y) { }
v2 operator+(v2 V) const { return v2(X + V.X, Y + V.Y); }
v2& operator+=(v2 V) { X += V.X; Y += V.Y; return *this; }
Expand Down
2 changes: 1 addition & 1 deletion FeLib/Source/error.cpp
Expand Up @@ -131,7 +131,7 @@ void globalerrorhandler::Abort(cchar* Format, ...)
std::cout << Buffer << std::endl;
#endif

DBGSTK;DBG2("ABORT:",Buffer);
DBGSTK;DBG2("ABORT:",Buffer);DBGBREAKPOINT;
exit(4);
}

Expand Down
28 changes: 25 additions & 3 deletions FeLib/Source/festring.cpp
Expand Up @@ -17,6 +17,8 @@
#include "allocate.h"
#include "error.h"

#include "dbgmsgproj.h"

char** festring::IntegerMap = 0;
cchar* const festring::EmptyString = "";
festring::csizetype festring::NPos = festring::sizetype(-1);
Expand All @@ -26,12 +28,32 @@ char Capitalize(char Char)
return (Char >= 'a' && Char <= 'z') ? (Char ^ 0x20) : Char;
}

void bugTrackInvalidChars(cchar* c,int size){
if(!c || !size)return;

//symbols and characters that are not "usually" expected
for(int i=0;i<size;i++){
static char C;C=c[i];
if(
(C < 0x20 || C > 0x7E)
&& C!='\r' && C!='\n' && C!='\t'
&& C!=0
// && C!='+' // o.O
){
/**
* after strenghtened festring, this now ends up being more useful to catch wrong usage of the permissive ADD_MESSAGE() passing a festring w/o .CStr()
*/
ABORT("string contains \"probably invalid\" chars, possibly a bug: \"%s\", [%d], 0x%X /0%o %d '%c'",c, i, C,C,C,C); //actual char '?' must be last as may break the string!
}
}
}

/* All operations that may change the underlying data will avoid touching the
memory allocator and deallocator as much as possible. They try very hard to
save memory and go for speed. */

festring& festring::operator=(cchar* CStr)
{
{DBGEXEC(bugTrackInvalidChars(CStr,strlen(CStr)));
CheckNull(CStr);

sizetype NewSize = strlen(CStr);
Expand All @@ -58,7 +80,7 @@ festring& festring::operator=(cchar* CStr)
}

festring& festring::operator=(staticstring SStr)
{
{DBGEXEC(bugTrackInvalidChars(SStr.Data,SStr.Size));
CheckNull(SStr.Data);

cchar* CStr = SStr.Data;
Expand All @@ -84,7 +106,7 @@ festring& festring::operator=(staticstring SStr)
}

festring& festring::operator=(cfestring& Str)
{
{DBGEXEC(bugTrackInvalidChars(Str.Data,Str.Size));
char* CStr = Str.Data;
sizetype NewSize = Str.Size;

Expand Down
2 changes: 1 addition & 1 deletion FeLib/Source/specialkeys.cpp
Expand Up @@ -178,7 +178,7 @@ bool specialkeys::ConsumeEvent(SKEvent e,festring& fsInOut){DBGLN;

std::stringstream ss(fsInOut.CStr());
std::string line;
while(std::getline(ss,line,'\n'))
while(std::getline(ss,line,'\n')) //TODO limit also by line length based on screen width
afsHelpDialog.push_back(festring(line.c_str()));

graphics::BlitDBToScreen();DBGLN;
Expand Down
2 changes: 1 addition & 1 deletion FeLib/Source/whandler.cpp
Expand Up @@ -340,7 +340,7 @@ void ShowFPS(){ //TODO still flickers sometimes cuz of silhouette?
static char c[100];

sprintf(c,"FPS:ls=%.1f,insta=%.1f",globalwindowhandler::GetFPS(false),globalwindowhandler::GetFPS(true));
int iDistX = strlen(c)*8 + 10;
int iDistX = strlen(c)*8 + 10 + 100; // +10 to look good, + 100 cuz of silhouette area
v2 v2Pos = RES-v2(iDistX,RES.Y)+v2Margin;
v2 v2Size(iDistX, 8+iMargin*2);

Expand Down
1 change: 1 addition & 0 deletions Main/Include/char.h
Expand Up @@ -1196,6 +1196,7 @@ class character : public entity, public id
void GetPlayerCommand();

truth AutoPlayAICommand(int&);
truth AutoPlayAIPray();
bool AutoPlayAIChkInconsistency();
static void AutoPlayAIDebugDrawSquareRect(v2 v2SqrPos, col16 color, int iPrintIndex=-1, bool bWide=false, bool bKeepColor=false);
static void AutoPlayAIDebugDrawOverlay();
Expand Down
1 change: 1 addition & 0 deletions Main/Include/confdef.h
Expand Up @@ -694,6 +694,7 @@
#define HOLY_TREE 3
#define CARPET 4
#define COUCH 5
#define CHAIR 6
#define DOUBLE_BED 9
#define POOL_BORDER 13
#define POOL_CORNER 14
Expand Down
1 change: 1 addition & 0 deletions Main/Include/game.h
Expand Up @@ -187,6 +187,7 @@ class game
static void SRegionAroundDeny();
static void PrepareToClearNonVisibleSquaresAround(v2);
static void UpdatePlayerOnScreenSBSBlitdata();
static truth IsQuestItem(item*);
static int GetMoveCommandKey(int);
static cv2 GetMoveVector(int I) { return MoveVector[I]; }
static cv2 GetClockwiseMoveVector(int I) { return ClockwiseMoveVector[I]; }
Expand Down
4 changes: 4 additions & 0 deletions Main/Include/iconf.h
Expand Up @@ -23,6 +23,7 @@ class ivanconfig
static cfestring& GetFantasyNamePattern() { return FantasyNamePattern.Value; }
static cfestring& GetDefaultPetName() { return DefaultPetName.Value; }
static cfestring& GetSelectedBkgColor() { return SelectedBkgColor.Value; }
static truth IsAllWeightIsRelevant() { return AllWeightIsRelevant.Value; }
static long GetAutoSaveInterval() { return AutoSaveInterval.Value; }
static long GetContrast() { return Contrast.Value; }
static long GetHitIndicator() { return HitIndicator.Value; }
Expand All @@ -32,6 +33,7 @@ class ivanconfig
static long GetFrameSkip() { return FrameSkip.Value; }
static long GetGoOnStopMode() { return GoOnStopMode.Value; }
static long GetHoldPosMaxDist() { return HoldPosMaxDist.Value; }
static truth IsShowVolume() { return ShowVolume.Value;}
static truth IsAllowImportOldSavegame(){ return AllowImportOldSavegame.Value; }
static long GetAltSilhouette() { return AltSilhouette.Value; }
static truth IsHideWeirdHitAnimationsThatLookLikeMiss(){return HideWeirdHitAnimationsThatLookLikeMiss.Value;}
Expand Down Expand Up @@ -189,6 +191,8 @@ class ivanconfig
static truthoption ShowMapAtDetectMaterial;
static truthoption TransparentMapLM;
static truthoption WaitNeutralsMoveAway;
static truthoption AllWeightIsRelevant;
static truthoption ShowVolume;
static truthoption EnhancedLights;

static cycleoption MemorizeEquipmentMode;
Expand Down
1 change: 1 addition & 0 deletions Main/Include/item.h
Expand Up @@ -629,6 +629,7 @@ class item : public object
virtual truth WeightIsIrrelevant() const { return false; }
virtual const prototype* FindProtoType() const { return &ProtoType; }
virtual truth AddStateDescription(festring&, truth) const;
virtual void AddContainerPostFix(festring&) const;
static const prototype ProtoType;
slot** Slot;
int Size;
Expand Down
2 changes: 2 additions & 0 deletions Main/Include/materias.h
Expand Up @@ -64,6 +64,8 @@ MATERIAL(organic, solid)
virtual material* EatEffect(character*, long);
virtual void AddConsumeEndMessage(character*) const;
virtual void SetSpoilCounter(int);
virtual ushort GetSpoilCounter();
virtual int CalcNewSpoilLevel();
virtual truth CanSpoil() const { return true; }
virtual int GetSpoilPercentage() const;
virtual truth Spoils() const { return true; }
Expand Down
2 changes: 1 addition & 1 deletion Main/Include/object.h
Expand Up @@ -86,7 +86,7 @@ class object : public entity, public id
virtual truth AddMaterialDescription(festring&, truth) const;
int RandomizeMaterialConfiguration();
virtual int GetClassAnimationFrames() const { return 1; }
void AddContainerPostFix(festring&) const;
virtual void AddContainerPostFix(festring&) const;
void AddLumpyPostFix(festring&) const;
truth AddEmptyAdjective(festring&, truth) const;
truth AddBurningAdjective(festring&, truth) const;
Expand Down
2 changes: 2 additions & 0 deletions Main/Include/traps.h
Expand Up @@ -44,6 +44,8 @@ TRAP(web, trap)
virtual void PreProcessForBone();
virtual void PostProcessForBone();
virtual void Untrap();
int GetRemoveTrapModifier(character* C);
truth TryToTearDown(character* C,int Modifier=-1);
protected:
trapdata TrapData;
bitmap* Picture;
Expand Down

0 comments on commit 13fd482

Please sign in to comment.