Skip to content

Commit

Permalink
> Fixed: buddy name
Browse files Browse the repository at this point in the history
> Fixed: protocol 28 for MenuGrid
> Fixed: deadlock of dowse
> Added: new fish resource
+Update
  • Loading branch information
Cediner committed Mar 18, 2024
1 parent b1c6b37 commit d22a56e
Show file tree
Hide file tree
Showing 23 changed files with 759 additions and 328 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<project name="hafen" default="deftgt">
<property name="name" value="ArdClient"/>
<property name="version" value="2024.03.17"/>
<property name="version" value="2024.03.18"/>

<target name="build-env">
<mkdir dir="build"/>
Expand Down
Binary file added custom-res/res/paginae/act/fish.res
Binary file not shown.
2 changes: 1 addition & 1 deletion src/haven/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public void run() {
while (task != null)
task = task.run();
} finally {
onClose.forEach(Runnable::run);
try {
alive = false;
for (Callback cb : cbs)
Expand All @@ -135,6 +134,7 @@ public void run() {
throw (new RuntimeException(e));
}
}
onClose.forEach(Runnable::run);
}
}
}
Expand Down
88 changes: 88 additions & 0 deletions src/haven/DRandom.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* This file is part of the Haven & Hearth game client.
* Copyright (C) 2009 Fredrik Tolf <fredrik@dolda2000.com>, and
* Björn Johannessen <johannessen.bjorn@gmail.com>
*
* Redistribution and/or modification of this file is subject to the
* terms of the GNU Lesser General Public License, version 3, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Other parts of this source tree adhere to other copying
* rights. Please see the file `COPYING' in the root directory of the
* source tree for details.
*
* A copy the GNU Lesser General Public License is distributed along
* with the source tree of which this file is a part in the file
* `doc/LPGL-3'. If it is missing for any reason, please see the Free
* Software Foundation's website at <http://www.fsf.org/>, or write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/

package haven;

import java.util.Random;

public class DRandom {
private final Random rnd = new Random(0);
private final long seed;

public DRandom() {
this.seed = new Random().nextLong();
}

public DRandom(long seed) {
this.seed = seed;
}

public DRandom(Random from) {
this(from.nextLong());
}

private Random seed(long a) {
rnd.setSeed(seed ^ a);
return (rnd);
}

private Random seed(long a, long b) {
rnd.setSeed(seed ^ a);
rnd.setSeed(rnd.nextLong() ^ b);
return (rnd);
}

private Random seed(long... a) {
rnd.setSeed(seed ^ a[0]);
for (int i = 1; i < a.length; i++)
rnd.setSeed(rnd.nextLong() ^ a[i]);
return (rnd);
}

public int randi(long a) {return (seed(a).nextInt());}

public int randi(long a, long b) {return (seed(a, b).nextInt());}

public int randi(long... a) {return (seed(a).nextInt());}

public long randl(long a) {return (seed(a).nextLong());}

public long randl(long a, long b) {return (seed(a, b).nextLong());}

public long randl(long... a) {return (seed(a).nextLong());}

public float randf(long a) {return (seed(a).nextFloat());}

public float randf(long a, long b) {return (seed(a, b).nextFloat());}

public float randf(long... a) {return (seed(a).nextFloat());}

public double randd(long a) {return (seed(a).nextDouble());}

public double randd(long a, long b) {return (seed(a, b).nextDouble());}

public double randd(long... a) {return (seed(a).nextDouble());}
}
7 changes: 4 additions & 3 deletions src/haven/DamageSprite.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package haven;

import haven.purus.pbot.PBotUtils;
import haven.res.ui.obj.buddy.Buddy;

import java.awt.Color;

Expand Down Expand Up @@ -79,9 +80,9 @@ public void update(int dmg, boolean isarmor) {
this.armtex = afrn.render(this.arm + "").tex();
} else {
if (Config.logcombatactions) {
KinInfo kininfo = gob.getattr(KinInfo.class);
if (kininfo != null)
PBotUtils.sysLogAppend(ui, "Hit " + kininfo.name + " For " + dmg + " Damage.", "green");
Buddy buddy = gob.getattr(Buddy.class);
if (buddy != null)
PBotUtils.sysLogAppend(ui, "Hit " + buddy.name() + " For " + dmg + " Damage.", "green");
else if (gob.isplayer())
PBotUtils.sysLogAppend(ui, "I got hit for " + dmg + " Damage.", "red");
else if (gob.getres().basename().contains("Body"))
Expand Down
7 changes: 4 additions & 3 deletions src/haven/Fightview.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package haven;


import haven.res.ui.obj.buddy.Buddy;
import haven.sloth.gfx.GobCombatSprite;
import haven.sloth.gob.AggroMark;
import haven.sloth.gui.MovableWidget;
Expand Down Expand Up @@ -174,9 +175,9 @@ public void use(Indir<Resource> act) {
}
OCache oc = ui.gui.map.glob.oc;
Gob gob = oc.getgob(gobid);
KinInfo kininfo = gob.getattr(KinInfo.class);
if (kininfo != null)
ui.gui.syslog.append(String.format("%s, %s, ip %d - %d", kininfo.name, tt.t, ip, oip), combatLogOpClr);
Buddy buddy = gob.getattr(Buddy.class);
if (buddy != null)
ui.gui.syslog.append(String.format("%s, %s, ip %d - %d", buddy.name(), tt.t, ip, oip), combatLogOpClr);
else if (gob.getres().basename().contains("body"))
ui.gui.syslog.append(String.format("Enemy Player, %s, ip %d - %d", tt.t, ip, oip), combatLogOpClr);
else
Expand Down
17 changes: 7 additions & 10 deletions src/haven/GameUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public class GameUI extends ConsoleHost implements Console.Directory, UI.Message
public CraftDBWnd craftwnd = null;
private TimersWnd timers;

public final List<DowseWnd> dowsewnds = new ArrayList<>();
public final List<DowseWnd> dowsewnds = Collections.synchronizedList(new ArrayList<>());
public ForageHelperWnd foragehelper;
public ForageWizardWnd forageWzrWnd;
public SkillnCredoWnd scwnd;
Expand Down Expand Up @@ -288,7 +288,7 @@ public void draw(GOut g) {
g.aimage(pinfo.tex(), new Coord(sz.x - x, y), 1, 0);
y += pinfo.sz().y;
}

Text winfo = ui.sess.glob.weathertimetex.get();
if (configuration.showweatherinfo && winfo != null) {
g.aimage(winfo.tex(), new Coord(sz.x - x, y), 1, 0);
Expand Down Expand Up @@ -1641,6 +1641,7 @@ else if (slot <= 99)
}

public final AtomicReference<Text> provincetex = new AtomicReference<>(null);

public void notifyProvince(Object... cargs) {
if (map != null) {
try {
Expand Down Expand Up @@ -2319,17 +2320,13 @@ public boolean mousewheel(Coord c, int amount) {
}

public DowseWnd makeDowseWnd(final Coord2d startc, final double a1, final double a2, final Consumer<Color> changeCol, final Runnable onClose) {
synchronized (dowsewnds) {
DowseWnd dwnd = new DowseWnd(startc, a1, a2, changeCol, onClose);
dowsewnds.add(add(dwnd));
return (dwnd);
}
DowseWnd dwnd = new DowseWnd(startc, a1, a2, changeCol, onClose);
dowsewnds.add(add(dwnd));
return (dwnd);
}

public void remDowseWnd(final DowseWnd wnd) {
synchronized (dowsewnds) {
dowsewnds.removeIf(wdg -> wdg == wnd);
}
dowsewnds.removeIf(wdg -> wdg == wnd);
}

@Override
Expand Down
12 changes: 8 additions & 4 deletions src/haven/Gob.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
import haven.res.lib.tree.Tree;
import haven.res.lib.vmat.Materials;
import haven.res.lib.vmat.VarSprite;
import haven.res.ui.obj.buddy.Buddy;
import haven.res.ui.obj.buddy.Info;
import haven.resutil.BPRadSprite;
import haven.resutil.RectSprite;
import haven.resutil.WaterTile;
Expand Down Expand Up @@ -503,7 +505,9 @@ private void recalc(Coord2d rc, double ra) {
if (a > ma) {
mn = n;
ma = a;
I = i; O = o; U = u;
I = i;
O = o;
U = u;
}
}
}
Expand Down Expand Up @@ -2055,7 +2059,7 @@ public Object staticp() {
break;
}
}
if (getattr(KinInfo.class) != null) {
if (getattr(Info.class) != null) {
rs = 2; //I want to see the names above fires/players without it being screwed up
}
switch (rs) {
Expand Down Expand Up @@ -2188,8 +2192,8 @@ public boolean isFriend() {
}
}

KinInfo kininfo = getattr(KinInfo.class);
if (kininfo == null || kininfo.group == 2 /*red*/)
Buddy buddy = getattr(Buddy.class);
if (buddy == null || buddy.group() == 2 /*red*/)
return false;

return true;
Expand Down
7 changes: 4 additions & 3 deletions src/haven/GobPath.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package haven;

import haven.res.ui.obj.buddy.Buddy;
import haven.sloth.gob.Movable;
import haven.sloth.gob.Type;
import modification.configuration;
Expand All @@ -21,9 +22,9 @@ public GobPath(Gob gob) {
clrst = Movable.animalpathcol;
} else {
//Humans, based off kin
final KinInfo kin = gob.getattr(KinInfo.class);
if (kin != null) {
clrst = Movable.buddycol[kin.group];
final Buddy buddy = gob.getattr(Buddy.class);
if (buddy != null) {
clrst = Movable.buddycol[buddy.group()];
} else {
clrst = Movable.unknowngobcol;
}
Expand Down

0 comments on commit d22a56e

Please sign in to comment.