Skip to content

Commit e79cef9

Browse files
committed
It compiles again!!!
1 parent f680683 commit e79cef9

9 files changed

+1125
-955
lines changed

GameObj.java

+27-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import java.util.*;
33
import java.lang.*;
44
import java.io.*;
5-
import com.dafttech.classloader.*;
5+
import org.lolhens.classfile.*;
66

77
/**
88
* Write a description of class GameObj here.
@@ -268,25 +268,34 @@ public static final Class getClassForId(int id) {
268268
}
269269

270270
public static final void loadGameObjects() {
271-
ClassDiscoverer discoverer = new ClassDiscoverer(GameObj.class, "");
272-
List<ContainedFile> classFiles = discoverer.discover();
273-
for (int i = classFiles.size() - 1; i >= 0; i--) {
274-
if (classFiles.get(i).toString().contains("PushyWorld")) classFiles.remove(i);
275-
}
276-
ClassFileLoader classFileLoader = new ClassFileLoader(classFiles);
277-
classFileLoader.setParentClassLoader(GameObj.class.getClassLoader());
278-
for (Class gameObjClass : classFileLoader.loadClasses()) {
279-
if (gameObjClass.toString().startsWith("class") && !gameObjClass.toString().contains(".") && gameObjClass != PushyWorld.class && gameObjClass != ObjectSelector.class) {
280-
Object gameObj = null;
281-
try {
282-
gameObj = gameObjClass.newInstance();
283-
} catch (Exception e) {
284-
}
285-
if (gameObj != null && gameObj instanceof GameObj) {
286-
testForId((GameObj) gameObj);
287-
gameObjects.add((GameObj) gameObj);
271+
try {
272+
Set<URLClassLocation> classLocations = new URLClassLocation(GameObj.class).discoverSourceURL();
273+
274+
Iterator<URLClassLocation> iterator = classLocations.iterator();
275+
while (iterator.hasNext())
276+
if (iterator.next().toString().contains("PushyWorld")) iterator.remove();
277+
278+
for (URLClassLocation classLocation : classLocations) {
279+
Class<?> gameObjClass = classLocation.loadClass(GameObj.class.getClassLoader());
280+
281+
if (gameObjClass.toString().startsWith("class") && !gameObjClass.toString().contains(".") && gameObjClass != PushyWorld.class && gameObjClass != ObjectSelector.class) {
282+
Object gameObj = null;
283+
284+
try {
285+
gameObj = gameObjClass.newInstance();
286+
} catch (Exception e) {
287+
}
288+
289+
if (gameObj != null && gameObj instanceof GameObj) {
290+
testForId((GameObj) gameObj);
291+
gameObjects.add((GameObj) gameObj);
292+
}
288293
}
289294
}
295+
} catch (IOException e) {
296+
return;
297+
} catch (ClassNotFoundException e) {
298+
return;
290299
}
291300
}
292301

LevelFile.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.io.*;
22
import java.util.*;
3-
import com.dafttech.network.packet.*;
3+
import org.lolhens.network.packet.*;
44
/**
55
* Write a description of class LevelFile here.
66
*
@@ -86,7 +86,7 @@ public void load() {
8686

8787
if (pushyWorld.networkInterface != null) {
8888
try {
89-
pushyWorld.networkInterface.send(new SimplePacket(3));
89+
//pushyWorld.networkInterface.send(new SimplePacket(3));
9090
} catch (Exception e) {
9191
}
9292
}
@@ -152,7 +152,7 @@ private void loadPe() {
152152
}
153153
if (pushyWorld.networkInterface != null) {
154154
try {
155-
pushyWorld.networkInterface.send(new SimplePacket(3));
155+
//pushyWorld.networkInterface.send(new SimplePacket(3));
156156
} catch (Exception e) {
157157
}
158158
}

LibEventManager-13.1.0+99.jar

102 KB
Binary file not shown.

LocalPushy.ctxt

+6-8
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ comment1.target=void\ onMove()
66
comment2.params=
77
comment2.target=void\ checkKeys()
88
comment3.params=client\ packet
9-
comment3.target=void\ receive(com.dafttech.network.Client,\ com.dafttech.network.packet.SimplePacket)
9+
comment3.target=void\ receive(org.lolhens.network.nio.Client,\ org.lolhens.network.packet.SimplePacket)
1010
comment4.params=client
11-
comment4.target=void\ connect(com.dafttech.network.Client)
11+
comment4.target=void\ connect(org.lolhens.network.nio.Client)
1212
comment5.params=client\ reason
13-
comment5.target=void\ disconnect(com.dafttech.network.Client,\ com.dafttech.network.disconnect.Disconnect)
14-
comment6.params=packet
15-
comment6.target=void\ receive(com.dafttech.network.packet.SimplePacket)
16-
comment7.params=
17-
comment7.target=int\ getId()
18-
numComments=8
13+
comment5.target=void\ disconnect(org.lolhens.network.nio.Client,\ org.lolhens.network.disconnect.DisconnectReason)
14+
comment6.params=
15+
comment6.target=int\ getId()
16+
numComments=7

LocalPushy.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
22
import javax.swing.*;
3-
import com.dafttech.network.*;
4-
import com.dafttech.network.packet.*;
5-
import com.dafttech.network.protocol.*;
6-
import com.dafttech.network.disconnect.*;
3+
import org.lolhens.network.*;
4+
import org.lolhens.network.packet.*;
5+
import org.lolhens.network.protocol.*;
6+
import org.lolhens.network.disconnect.*;
7+
import org.lolhens.network.nio.*;
78
/**
89
* Write a description of class LocalPushy here.
910
*
@@ -75,10 +76,10 @@ private void checkKeys()
7576
if (address != null) {
7677
try {
7778
if (serverMode.toLowerCase().equals("y")) {
78-
getWorld().networkInterface = new Server<SimplePacket>(SimpleProtocol.class, address) {
79+
getWorld().networkInterface = new Server<SimplePacket>(SimpleProtocol.class) { //, address
7980
public void receive(Client<SimplePacket> client, SimplePacket packet) {
8081
getWorld().packetQueue.add(packet);
81-
for (Client<SimplePacket> cClient : getClients()) {
82+
for (AbstractClient<SimplePacket> cClient : getClients()) {
8283
try {
8384
if (cClient != client) cClient.send(packet);
8485
} catch (Exception e) {
@@ -88,9 +89,9 @@ public void receive(Client<SimplePacket> client, SimplePacket packet) {
8889
}
8990

9091
public void connect(Client<SimplePacket> client) {
91-
for (Client<SimplePacket> cClient : getClients()) {
92+
for (AbstractClient<SimplePacket> cClient : getClients()) {
9293
try {
93-
if (cClient != client) cClient.send(new SimplePacket(4));
94+
//if (cClient != client) cClient.send(new SimplePacket(4));
9495
} catch (Exception e) {
9596
e.printStackTrace();
9697
}
@@ -108,7 +109,7 @@ public void connect(Client<SimplePacket> client) {
108109
getWorld().send();
109110
}
110111

111-
public void disconnect(Client<SimplePacket> client, Disconnect reason) {
112+
public void disconnect(Client<SimplePacket> client, DisconnectReason reason) {
112113
for (Object obj : getWorld().getObjects(null)) {
113114
if (obj instanceof RemotePushy) {
114115
if (((RemotePushy)obj).client == client) ((GameObj)obj).remove();
@@ -117,10 +118,10 @@ public void disconnect(Client<SimplePacket> client, Disconnect reason) {
117118
}
118119
};
119120
} else {
120-
getWorld().networkInterface = new Client<SimplePacket>(SimpleProtocol.class, address) {
121-
public void receive(SimplePacket packet) {
121+
getWorld().networkInterface = new Client<SimplePacket>(SimpleProtocol.class) { //, address
122+
/*public void receive(SimplePacket packet) {
122123
getWorld().packetQueue.add(packet);
123-
}
124+
}*/
124125
};
125126
}
126127
} catch (Exception e) {

PushyWorld.ctxt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ comment3.target=void\ send()
2020
comment4.params=x\ y
2121
comment4.target=void\ send(int,\ int)
2222
comment5.params=packet
23-
comment5.target=void\ processPacket(com.dafttech.network.packet.SimplePacket)
23+
comment5.target=void\ processPacket(org.lolhens.network.packet.SimplePacket)
2424
comment6.params=
2525
comment6.target=void\ act()
2626
comment7.params=x\ y

PushyWorld.java

+15-14
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
import java.util.*;
33
import java.io.*;
44
import java.nio.*;
5-
import com.dafttech.network.*;
6-
import com.dafttech.network.packet.*;
7-
import com.dafttech.network.protocol.*;
8-
import com.dafttech.classloader.*;
9-
import com.dafttech.primitive.*;
5+
import org.lolhens.network.*;
6+
import org.lolhens.network.packet.*;
7+
import org.lolhens.network.protocol.*;
8+
import org.lolhens.classfile.*;
9+
import org.lolhens.primitive.*;
1010
import javax.swing.*;
1111

1212
/**
@@ -21,7 +21,7 @@ public class PushyWorld extends World
2121
private GameObj dragged = null;
2222
public ExtraData extraData = new ExtraData();
2323
KeyManager keyManager = new KeyManager();
24-
public NetworkInterface<SimplePacket> networkInterface = null;
24+
public ProtocolProvider<SimplePacket> networkInterface = null;
2525
public List<SimplePacket> packetQueue = new ArrayList<SimplePacket>();
2626
public PushyWorld()
2727
{
@@ -53,7 +53,7 @@ public void send() {
5353
ByteArrayOutputStream stream = new ByteArrayOutputStream();
5454
new LevelFile(this).writePe(new DataOutputStream(stream));
5555
byte[] bytes = stream.toByteArray();
56-
networkInterface.send(new SimplePacket(0, bytes));
56+
//networkInterface.send(new SimplePacket(0, bytes));
5757
} catch (Exception e) {
5858
e.printStackTrace();
5959
}
@@ -65,8 +65,8 @@ public void send(int x, int y) {
6565
try {
6666
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
6767
DataOutputStream stream = new DataOutputStream(byteStream);
68-
stream.write(Primitive.INT.toByteArray(x));
69-
stream.write(Primitive.INT.toByteArray(y));
68+
stream.write(PrimitiveUtil.INTEGER.toByteArray(x, ByteOrder.BIG_ENDIAN));
69+
stream.write(PrimitiveUtil.INTEGER.toByteArray(y, ByteOrder.BIG_ENDIAN));
7070
GameObj gameObj = null;
7171
for (Object obj : getObjects(null)) {
7272
if (obj instanceof GameObj) {
@@ -84,7 +84,7 @@ public void send(int x, int y) {
8484
}
8585
}
8686
byte[] bytes = byteStream.toByteArray();
87-
networkInterface.send(new SimplePacket(1, bytes));
87+
//networkInterface.send(new SimplePacket(1, bytes));
8888
} catch (Exception e) {
8989
e.printStackTrace();
9090
}
@@ -101,8 +101,8 @@ public void processPacket(SimplePacket packet) {
101101
e.printStackTrace();
102102
}
103103
} else if (packet.channel == 1) {
104-
int x = Primitive.INT.fromByteArray(packet.data);
105-
int y = Primitive.INT.fromByteArray(packet.data, 4);
104+
int x = PrimitiveUtil.INTEGER.fromByteArray(packet.data, ByteOrder.BIG_ENDIAN);
105+
int y = PrimitiveUtil.INTEGER.fromByteArray(packet.data, 4, ByteOrder.BIG_ENDIAN);
106106
ByteArrayInputStream inputStream = new ByteArrayInputStream(Arrays.copyOfRange(packet.data, 8, packet.data.length));
107107
for (Object obj : getObjects(null)) {
108108
if (obj instanceof GameObj) {
@@ -135,7 +135,7 @@ public void processPacket(SimplePacket packet) {
135135
GameObj.reading = false;
136136
} else if (packet.channel == 3) {
137137
try {
138-
networkInterface.send(new SimplePacket(4));
138+
//networkInterface.send(new SimplePacket(4));
139139
} catch (Exception e) {
140140
}
141141
} else if (packet.channel == 4) {
@@ -196,6 +196,7 @@ public void act() {
196196
public GameObj getTopmostGameObjAt(int x, int y) {
197197
GameObj topmost = null;
198198
for (Object obj : getObjectsAt(x, y, null)) {
199+
if (!(obj instanceof GameObj)) continue;
199200
GameObj gameObj = (GameObj) obj;
200201
if (!gameObj.isDead() && !(gameObj instanceof Tool) &&
201202
(topmost == null || gameObj.getRenderOrder() > topmost.getRenderOrder())) topmost = gameObj;
@@ -264,7 +265,7 @@ public void clear() {
264265
extraData.putInt("openGoals", 0);
265266
addObject(new Menu(), 2, 0);
266267
try {
267-
if (!GameObj.reading && networkInterface != null) networkInterface.send(new SimplePacket(2, new byte[0]));
268+
//if (!GameObj.reading && networkInterface != null) networkInterface.send(new SimplePacket(2, new byte[0]));
268269
} catch (Exception e) {
269270
e.printStackTrace();
270271
}

RemotePushy.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
2-
import com.dafttech.network.*;
2+
import org.lolhens.network.*;
33

44
/**
55
* Write a description of class RemotePushy here.
@@ -9,7 +9,7 @@
99
*/
1010
public class RemotePushy extends Pushy
1111
{
12-
public Client<?> client;
12+
public AbstractClient<?> client;
1313

1414
public void update()
1515
{

0 commit comments

Comments
 (0)