Skip to content

Instantly share code, notes, and snippets.

@ericoporto
Created September 26, 2019 01:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericoporto/6a15950e4cd8ce9b1f73155b47a4196d to your computer and use it in GitHub Desktop.
Save ericoporto/6a15950e4cd8ce9b1f73155b47a4196d to your computer and use it in GitHub Desktop.
changes from 1byte to short
diff --git a/Common/ac/characterinfo.cpp b/Common/ac/characterinfo.cpp
index dbcbcf39..2cfb1561 100644
--- a/Common/ac/characterinfo.cpp
+++ b/Common/ac/characterinfo.cpp
@@ -31,7 +31,7 @@ void CharacterInfo::ReadFromFile(Stream *in)
wait = in->ReadInt32();
flags = in->ReadInt32();
following = in->ReadInt16();
- followinfo = in->ReadInt16();
+ followinfo = in->ReadInt32();
idleview = in->ReadInt32();
idletime = in->ReadInt16();
idleleft = in->ReadInt16();
@@ -81,7 +81,7 @@ void CharacterInfo::WriteToFile(Stream *out)
out->WriteInt32(wait);
out->WriteInt32(flags);
out->WriteInt16(following);
- out->WriteInt16(followinfo);
+ out->WriteInt32(followinfo);
out->WriteInt32(idleview);
out->WriteInt16(idletime);
out->WriteInt16(idleleft);
diff --git a/Common/ac/characterinfo.h b/Common/ac/characterinfo.h
index f3140d15..65ba1ccb 100644
--- a/Common/ac/characterinfo.h
+++ b/Common/ac/characterinfo.h
@@ -44,7 +44,7 @@ using namespace AGS; // FIXME later
#define OCHF_SPEECHCOL 0xff000000
#define OCHF_SPEECHCOLSHIFT 24
#define UNIFORM_WALK_SPEED 0
-#define FOLLOW_ALWAYSONTOP 0x7ffe
+#define FOLLOW_ALWAYSONTOP 0x7ffffffe
struct CharacterExtras; // forward declaration
// remember - if change this struct, also change AGSDEFNS.SH and
@@ -57,7 +57,7 @@ struct CharacterInfo {
int x, y, wait;
int flags;
short following;
- short followinfo;
+ int followinfo;
int idleview; // the loop will be randomly picked
short idletime, idleleft; // num seconds idle before playing anim
short transparency; // if character is transparent
diff --git a/Engine/ac/character.cpp b/Engine/ac/character.cpp
index 5eb3a21c..07c56cce 100644
--- a/Engine/ac/character.cpp
+++ b/Engine/ac/character.cpp
@@ -495,7 +495,7 @@ void Character_FollowCharacter(CharacterInfo *chaa, CharacterInfo *tofollow, int
else
chaa->following = tofollow->index_id;
- chaa->followinfo=(distaway << 8) | eagerness;
+ chaa->followinfo=(distaway << 16) | eagerness;
chaa->flags &= ~CHF_BEHINDSHEPHERD;
diff --git a/Engine/ac/characterinfo_engine.cpp b/Engine/ac/characterinfo_engine.cpp
index 8f6f1a5a..e16a69c7 100644
--- a/Engine/ac/characterinfo_engine.cpp
+++ b/Engine/ac/characterinfo_engine.cpp
@@ -388,7 +388,7 @@ void CharacterInfo::update_character_follower(int &aa, int &numSheep, int *follo
}
// not moving, but should be following another character
else if ((following >= 0) && (doing_nothing == 1)) {
- short distaway=(followinfo >> 8) & 0x00ff;
+ short distaway=(followinfo >> 16) & 0x00ffff;
// no character in this room
if ((game.chars[following].on == 0) || (on == 0)) ;
else if (room < 0) {
@@ -401,7 +401,7 @@ void CharacterInfo::update_character_follower(int &aa, int &numSheep, int *follo
}
}
// wait a bit, so we're not constantly walking
- else if (Random(100) < (followinfo & 0x00ff)) ;
+ else if (Random(100) < (followinfo & 0x00ffff)) ;
// the followed character has changed room
else if ((room != game.chars[following].room)
&& (game.chars[following].on == 0))
@@ -446,7 +446,7 @@ void CharacterInfo::update_character_follower(int &aa, int &numSheep, int *follo
}
else if ((abs(game.chars[following].x - x) > distaway+30) |
(abs(game.chars[following].y - y) > distaway+30) |
- ((followinfo & 0x00ff) == 0)) {
+ ((followinfo & 0x00ffff) == 0)) {
// in same room
int goxoffs=(Random(50)-25);
// make sure he's not standing on top of the other man
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment