game_machine 0.0.11 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +12 -1
- data/Gemfile.lock +32 -47
- data/Rakefile +0 -27
- data/bin/bundle_run.sh +1 -0
- data/bin/game_machine +29 -27
- data/config/cluster.conf +6 -5
- data/config/default.conf +164 -0
- data/config/game_machine.sql +33 -0
- data/config/game_messages.proto +87 -25
- data/config/gamecloud.conf +140 -0
- data/config/messages.proto +46 -53
- data/config/test.conf +149 -0
- data/game_machine.gemspec +10 -5
- data/games/boot.rb +3 -0
- data/games/example/data/game_data.yml +4 -4
- data/games/example/lib/aggressive_npc.rb +1 -1
- data/games/example/lib/game.rb +1 -2
- data/games/example/lib/player_register.rb +1 -1
- data/games/routes.rb +9 -0
- data/games/tutorial/boot.rb +12 -0
- data/games/tutorial/item_manager.rb +256 -0
- data/games/tutorial/object_store.rb +55 -0
- data/games/tutorial/seed.rb +52 -0
- data/games/tutorial/sql_store.rb +30 -0
- data/java/project/build.gradle +134 -0
- data/java/project/component.erb +719 -0
- data/java/{gradle.properties → project/gradle.properties} +1 -1
- data/java/project/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/java/{gradle → project/gradle}/wrapper/gradle-wrapper.properties +2 -2
- data/java/{gradlew → project/gradlew} +0 -0
- data/java/{gradlew.bat → project/gradlew.bat} +0 -0
- data/java/project/local_lib/AdminUi.jar +0 -0
- data/java/{local_lib/protostuff-compiler-1.0.7-jarjar.jar → project/local_lib/protostuff-compiler-1.0.8-jarjar.jar} +0 -0
- data/java/project/local_lib/sigar/libsigar-amd64-freebsd-6.so +0 -0
- data/java/project/local_lib/sigar/libsigar-amd64-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-amd64-solaris.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ia64-hpux-11.sl +0 -0
- data/java/project/local_lib/sigar/libsigar-ia64-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-pa-hpux-11.sl +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc-aix-5.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc64-aix-5.so +0 -0
- data/java/project/local_lib/sigar/libsigar-ppc64-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-s390x-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-sparc-solaris.so +0 -0
- data/java/project/local_lib/sigar/libsigar-sparc64-solaris.so +0 -0
- data/java/project/local_lib/sigar/libsigar-universal-macosx.dylib +0 -0
- data/java/project/local_lib/sigar/libsigar-universal64-macosx.dylib +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-freebsd-5.so +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-freebsd-6.so +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-linux.so +0 -0
- data/java/project/local_lib/sigar/libsigar-x86-solaris.so +0 -0
- data/java/project/local_lib/sigar/sigar-amd64-winnt.dll +0 -0
- data/java/project/local_lib/sigar/sigar-x86-winnt.dll +0 -0
- data/java/project/local_lib/sigar/sigar-x86-winnt.lib +0 -0
- data/java/project/model.erb +99 -0
- data/java/{settings.gradle → project/settings.gradle} +0 -0
- data/java/project/src/main/java/com/game_machine/authentication/DefaultAuthenticator.java +28 -0
- data/java/project/src/main/java/com/game_machine/authentication/PlayerAuthenticator.java +6 -0
- data/java/project/src/main/java/com/game_machine/authentication/PublicAuthenticator.java +20 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/ActorFactory.java +0 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/ActorUtil.java +13 -0
- data/java/project/src/main/java/com/game_machine/core/AuthorizedPlayers.java +23 -0
- data/java/project/src/main/java/com/game_machine/core/ClientMessageDecoder.java +36 -0
- data/java/project/src/main/java/com/game_machine/core/ClientMessageEncoder.java +19 -0
- data/java/project/src/main/java/com/game_machine/core/CloudClient.java +298 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/CommandProxy.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/Commands.java +20 -0
- data/java/project/src/main/java/com/game_machine/core/DatastoreCommands.java +43 -0
- data/java/project/src/main/java/com/game_machine/core/DbConnectionPool.java +72 -0
- data/java/project/src/main/java/com/game_machine/core/DefaultMovementVerifier.java +56 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/EntitySerializer.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/EntityTracking.java +119 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/EventStreamHandler.java +1 -1
- data/java/project/src/main/java/com/game_machine/core/GameActor.java +73 -0
- data/java/project/src/main/java/com/game_machine/core/GameMachineLoader.java +43 -0
- data/java/project/src/main/java/com/game_machine/core/GameMessageActor.java +44 -0
- data/java/project/src/main/java/com/game_machine/core/Grid.java +255 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/GridValue.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/Hashring.java +66 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/IActorFactory.java +0 -0
- data/java/project/src/main/java/com/game_machine/core/LocalLinkedBuffer.java +20 -0
- data/java/project/src/main/java/com/game_machine/core/MessageGateway.java +120 -0
- data/java/project/src/main/java/com/game_machine/core/MessagePersister.java +26 -0
- data/java/project/src/main/java/com/game_machine/core/MonoProxy.java +39 -0
- data/java/project/src/main/java/com/game_machine/core/MovementVerifier.java +7 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/NetMessage.java +10 -6
- data/java/project/src/main/java/com/game_machine/core/PersistentMessage.java +9 -0
- data/java/project/src/main/java/com/game_machine/core/PlayerCommands.java +31 -0
- data/java/project/src/main/java/com/game_machine/core/TcpServer.java +100 -0
- data/java/project/src/main/java/com/game_machine/core/TcpServerHandler.java +54 -0
- data/java/project/src/main/java/com/game_machine/core/TcpServerInitializer.java +32 -0
- data/java/project/src/main/java/com/game_machine/core/UdpClient.java +86 -0
- data/java/{src → project/src}/main/java/com/game_machine/core/UdpServer.java +18 -27
- data/java/{src → project/src}/main/java/com/game_machine/core/UdpServerHandler.java +23 -26
- data/java/project/src/main/java/com/game_machine/core/Vector3.java +159 -0
- data/java/project/src/main/java/com/game_machine/orm/models/PlayerItem.java +118 -0
- data/java/project/src/main/java/com/game_machine/orm/models/TestObject.java +110 -0
- data/java/project/src/main/java/com/game_machine/tutorial/LootGenerator.java +26 -0
- data/java/{src → project/src}/main/resources/game_machine.java.stg +3 -1
- data/java/project/src/main/resources/logback.properties +13 -0
- data/java/project/src/main/resources/logback.xml +76 -0
- data/java/{src → project/src}/main/resources/protostuff.properties +0 -0
- data/java/src/main/java/game/MyGameActor.java +26 -0
- data/lib/game_machine.rb +17 -16
- data/lib/game_machine/actor.rb +1 -1
- data/lib/game_machine/actor/base.rb +8 -31
- data/lib/game_machine/actor/builder.rb +5 -6
- data/lib/game_machine/actor/game_actor.rb +55 -0
- data/lib/game_machine/actor/reloadable.rb +6 -1
- data/lib/game_machine/akka.rb +26 -32
- data/lib/game_machine/app_config.rb +39 -26
- data/lib/game_machine/application.rb +56 -62
- data/lib/game_machine/client_manager.rb +14 -8
- data/lib/game_machine/cloud_updater.rb +51 -0
- data/lib/game_machine/cluster_monitor.rb +3 -3
- data/lib/game_machine/commands.rb +1 -1
- data/lib/game_machine/commands/misc_commands.rb +4 -8
- data/lib/game_machine/commands/player_commands.rb +8 -0
- data/lib/game_machine/console.rb +1 -0
- data/lib/game_machine/console/build.rb +57 -24
- data/lib/game_machine/console/bundle.rb +95 -0
- data/lib/game_machine/console/deploy.rb +30 -0
- data/lib/game_machine/console/install.rb +70 -36
- data/lib/game_machine/console/server.rb +2 -69
- data/lib/game_machine/data_store.rb +111 -15
- data/lib/game_machine/data_stores/couchbase.rb +8 -3
- data/lib/game_machine/data_stores/gamecloud.rb +93 -0
- data/lib/game_machine/data_stores/jdbc.rb +98 -0
- data/lib/game_machine/default_handlers.rb +2 -0
- data/lib/game_machine/default_handlers/team_handler.rb +51 -0
- data/lib/game_machine/default_handlers/zone_manager.rb +30 -0
- data/lib/game_machine/endpoints.rb +0 -4
- data/lib/game_machine/endpoints/udp_incoming.rb +13 -5
- data/lib/game_machine/endpoints/udp_outgoing.rb +15 -9
- data/lib/game_machine/game_systems.rb +0 -2
- data/lib/game_machine/game_systems/agents/controller.rb +2 -2
- data/lib/game_machine/game_systems/entity_tracking.rb +0 -3
- data/lib/game_machine/game_systems/region_manager.rb +3 -2
- data/lib/game_machine/game_systems/region_service.rb +2 -2
- data/lib/game_machine/game_systems/remote_echo.rb +10 -0
- data/lib/game_machine/game_systems/team_manager.rb +2 -11
- data/lib/game_machine/grid.rb +5 -18
- data/lib/game_machine/handlers/authentication.rb +1 -9
- data/lib/game_machine/handlers/game.rb +27 -2
- data/lib/game_machine/handlers/player_authentication.rb +87 -0
- data/lib/game_machine/handlers/request.rb +9 -11
- data/lib/game_machine/hocon_config.rb +81 -0
- data/lib/game_machine/java_lib.rb +14 -1
- data/lib/game_machine/logger.rb +10 -23
- data/lib/game_machine/models.rb +1 -0
- data/lib/game_machine/mono_server.rb +6 -1
- data/lib/game_machine/object_db.rb +12 -6
- data/lib/game_machine/protobuf.rb +1 -1
- data/lib/game_machine/protobuf/game_messages.rb +13 -3
- data/lib/game_machine/protobuf/generate.rb +107 -5
- data/lib/game_machine/restart_watcher.rb +1 -1
- data/lib/game_machine/routes.rb +23 -0
- data/lib/game_machine/scheduler.rb +1 -1
- data/lib/game_machine/securerandom.rb +2 -0
- data/lib/game_machine/system_stats.rb +28 -7
- data/lib/game_machine/version.rb +1 -1
- data/lib/game_machine/wavefront_ext.rb +47 -0
- data/lib/game_machine/write_behind_cache.rb +24 -9
- data/mono/server/Makefile +1 -1
- data/mono/server/Newtonsoft.Json.dll +0 -0
- data/mono/server/build.bat +1 -1
- data/mono/server/callable.cs +9 -0
- data/mono/server/echo.cs +17 -0
- data/mono/server/message_router.cs +16 -23
- data/mono/server/messages.cs +1792 -417
- data/mono/server/protobuf-net.dll +0 -0
- data/mono/server/server.cs +120 -0
- data/mono/server/server.exe +0 -0
- data/pathfinding/astar.cpp +149 -0
- data/pathfinding/build.sh +6 -0
- data/pathfinding/build.txt +16 -0
- data/pathfinding/crowd.cpp +194 -0
- data/pathfinding/include/astar.h +49 -0
- data/pathfinding/include/common.h +5 -0
- data/pathfinding/include/crowd.h +43 -0
- data/pathfinding/include/micropather.h +511 -0
- data/pathfinding/include/navmesh.h +114 -0
- data/pathfinding/include/pathfinder.h +24 -0
- data/pathfinding/main.cpp +108 -17
- data/pathfinding/micropather.cpp +1062 -0
- data/pathfinding/navmesh.cpp +408 -0
- data/pathfinding/overrides/DetourCrowd.cpp +1446 -0
- data/pathfinding/overrides/DetourNavMeshQuery.cpp +3551 -0
- data/pathfinding/overrides/DetourNavMeshQuery.h +538 -0
- data/pathfinding/pathfinder.cpp +117 -0
- data/pathfinding/{bin → premake}/premake4 +0 -0
- data/pathfinding/premake/premake4.exe +0 -0
- data/pathfinding/premake4.lua +12 -3
- data/spec/actor/actor_spec.rb +0 -7
- data/spec/client_manager_spec.rb +1 -1
- data/spec/couchproxy_spec.rb +38 -0
- data/spec/entity_persistence_spec.rb +129 -0
- data/spec/game_systems/team_manager_spec.rb +2 -2
- data/spec/hashring_spec.rb +17 -39
- data/spec/java_grid_spec.rb +0 -2
- data/spec/misc_spec.rb +111 -0
- data/spec/mono_spec.rb +50 -3
- data/spec/reliable_message_spec.rb +38 -0
- data/spec/spec_helper.rb +4 -4
- data/spec/spec_helper_minimal.rb +10 -0
- data/web/app.rb +108 -86
- data/web/config/trinidad.yml +1 -0
- data/web/views/add_player.erb +25 -0
- data/web/views/index.erb +0 -0
- data/web/views/layout.erb +48 -0
- data/web/views/login.erb +25 -0
- data/web/views/players.erb +24 -0
- metadata +209 -94
- data/config/config.example.yml +0 -100
- data/config/regions.example.yml +0 -9
- data/games/example/lib/authentication_handler.rb +0 -69
- data/games/models.rb +0 -3
- data/games/models/clan_member.rb +0 -8
- data/games/models/clan_profile.rb +0 -9
- data/games/models/player.rb +0 -7
- data/games/plugins.rb +0 -1
- data/games/plugins/team_handler.rb +0 -49
- data/games/preload.rb +0 -13
- data/java/.gitignore +0 -1
- data/java/build.gradle +0 -95
- data/java/component.erb +0 -396
- data/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/java/src/main/java/com/game_machine/core/GameMachineLoader.java +0 -25
- data/java/src/main/java/com/game_machine/core/Grid.java +0 -195
- data/java/src/main/resources/logback.xml +0 -14
- data/java/src/main/resources/logging.properties +0 -3
- data/lib/game_machine/actor/mono_actor.rb +0 -89
- data/lib/game_machine/auth_handlers/base.rb +0 -21
- data/lib/game_machine/auth_handlers/public.rb +0 -34
- data/lib/game_machine/endpoints/mono_gateway.rb +0 -87
- data/lib/game_machine/endpoints/tcp.rb +0 -51
- data/lib/game_machine/endpoints/tcp_handler.rb +0 -75
- data/lib/game_machine/endpoints/udp.rb +0 -88
- data/lib/game_machine/game_loader.rb +0 -46
- data/lib/game_machine/game_systems/region_settings.rb +0 -13
- data/lib/game_machine/hashring.rb +0 -48
- data/lib/game_machine/settings.rb +0 -11
- data/mono/server/actor.cs +0 -37
- data/mono/server/iactor.cs +0 -11
- data/mono/server/message_util.cs +0 -29
- data/mono/server/proxy_client.cs +0 -73
- data/mono/server/proxy_server.cs +0 -30
- data/mono/server/test_actor.cs +0 -33
- data/pathfinding/include/pathfind.h +0 -167
- data/pathfinding/pathfind.cpp +0 -174
- data/pathfinding/pathfinder.cs +0 -66
- data/script/server.sh +0 -109
- data/script/watch.sh +0 -11
- data/spec/commands/navigation_commands_spec.rb +0 -51
- data/spec/game_systems/entity_tracking_spec.rb +0 -64
- data/spec/navigation/detour_navmesh_spec.rb +0 -34
- data/spec/navigation/detour_path_spec.rb +0 -25
- data/spec/udp_server_spec.rb +0 -10
- data/web/controllers/auth_controller.rb +0 -19
- data/web/controllers/base_controller.rb +0 -16
- data/web/controllers/index_controller.rb +0 -7
- data/web/controllers/log_controller.rb +0 -47
- data/web/controllers/messages_controller.rb +0 -59
- data/web/controllers/player_register_controller.rb +0 -15
- data/web/views/game_messages.haml +0 -45
- data/web/views/index.haml +0 -6
- data/web/views/layout.haml +0 -41
- data/web/views/logs.haml +0 -32
- data/web/views/player_register.haml +0 -22
- data/web/views/player_registered.haml +0 -2
- data/web/views/register_layout.haml +0 -22
- data/web/views/restart.haml +0 -35
Binary file
|
@@ -1,25 +0,0 @@
|
|
1
|
-
package com.game_machine.core;
|
2
|
-
|
3
|
-
import java.util.logging.Logger;
|
4
|
-
|
5
|
-
import akka.actor.ActorSystem;
|
6
|
-
import akka.actor.Props;
|
7
|
-
|
8
|
-
public class GameMachineLoader {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
private static final Logger log = Logger.getLogger(GameMachineLoader.class.getName());
|
13
|
-
private static ActorSystem actorSystem;
|
14
|
-
|
15
|
-
public static ActorSystem getActorSystem() {
|
16
|
-
return actorSystem;
|
17
|
-
}
|
18
|
-
|
19
|
-
public void run(ActorSystem newActorSystem, String gameHandler) {
|
20
|
-
Thread.currentThread().setName("game-machine");
|
21
|
-
actorSystem = newActorSystem;
|
22
|
-
actorSystem.actorOf(Props.create(EventStreamHandler.class), EventStreamHandler.class.getSimpleName());
|
23
|
-
}
|
24
|
-
|
25
|
-
}
|
@@ -1,195 +0,0 @@
|
|
1
|
-
package com.game_machine.core;
|
2
|
-
|
3
|
-
import java.util.ArrayList;
|
4
|
-
import java.util.HashSet;
|
5
|
-
import java.util.Set;
|
6
|
-
import java.util.concurrent.ConcurrentHashMap;
|
7
|
-
|
8
|
-
public class Grid {
|
9
|
-
|
10
|
-
private float max;
|
11
|
-
private int cellSize = 0;
|
12
|
-
private float convFactor;
|
13
|
-
private int width;
|
14
|
-
private int cellCount;
|
15
|
-
|
16
|
-
public ConcurrentHashMap<String, GridValue> deltaIndex = new ConcurrentHashMap<String, GridValue>();
|
17
|
-
public ConcurrentHashMap<String, GridValue> objectIndex = new ConcurrentHashMap<String, GridValue>();
|
18
|
-
public ConcurrentHashMap<Integer, ConcurrentHashMap<String, GridValue>> cells = new ConcurrentHashMap<Integer, ConcurrentHashMap<String, GridValue>>();
|
19
|
-
public ConcurrentHashMap<Integer, Set<Integer>> cellsCache = new ConcurrentHashMap<Integer, Set<Integer>>();
|
20
|
-
|
21
|
-
public Grid(int max, int cellSize) {
|
22
|
-
this.max = max;
|
23
|
-
this.cellSize = cellSize;
|
24
|
-
this.convFactor = 1.0f / this.cellSize;
|
25
|
-
this.width = (int) (this.max / this.cellSize);
|
26
|
-
this.cellCount = this.width * this.width;
|
27
|
-
}
|
28
|
-
|
29
|
-
public int getWidth() {
|
30
|
-
return this.width;
|
31
|
-
}
|
32
|
-
|
33
|
-
public int getCellCount() {
|
34
|
-
return this.cellCount;
|
35
|
-
}
|
36
|
-
|
37
|
-
public Set<Integer> cellsWithinRadius(float x, float y) {
|
38
|
-
int cellHash = hash(x, y);
|
39
|
-
return cellsWithinRadius(cellHash, x, y);
|
40
|
-
}
|
41
|
-
|
42
|
-
public Set<Integer> cellsWithinRadius(int cellHash, float x, float y) {
|
43
|
-
int key = cellHash;
|
44
|
-
Set<Integer> cells = cellsCache.get(key);
|
45
|
-
if (cells != null) {
|
46
|
-
return cells;
|
47
|
-
}
|
48
|
-
cells = new HashSet<Integer>();
|
49
|
-
|
50
|
-
int offset = this.cellSize;
|
51
|
-
|
52
|
-
int startX = (int) (x - offset);
|
53
|
-
int startY = (int) (y - offset);
|
54
|
-
int endX = (int) (x + offset);
|
55
|
-
int endY = (int) (y + offset);
|
56
|
-
|
57
|
-
for (int rowNum = startX; rowNum <= endX; rowNum += this.cellSize) {
|
58
|
-
for (int colNum = startY; colNum <= endY; colNum += this.cellSize) {
|
59
|
-
if (rowNum >= 0 && colNum >= 0) {
|
60
|
-
cells.add(hash(rowNum, colNum));
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
64
|
-
cellsCache.put(key, cells);
|
65
|
-
return cells;
|
66
|
-
}
|
67
|
-
|
68
|
-
public ArrayList<GridValue> neighbors(float x, float y, String entityType) {
|
69
|
-
int myCell = hash(x, y);
|
70
|
-
return neighbors(myCell, x, y, entityType);
|
71
|
-
}
|
72
|
-
|
73
|
-
public ArrayList<GridValue> neighbors(int myCell, float x, float y, String entityType) {
|
74
|
-
ArrayList<GridValue> result;
|
75
|
-
|
76
|
-
GridValue[] gridValues;
|
77
|
-
result = new ArrayList<GridValue>();
|
78
|
-
Set<Integer> cells = cellsWithinRadius(myCell, x, y);
|
79
|
-
for (int cell : cells) {
|
80
|
-
gridValues = gridValuesInCell(cell);
|
81
|
-
if (gridValues != null) {
|
82
|
-
for (GridValue gridValue : gridValues) {
|
83
|
-
if (gridValue != null) {
|
84
|
-
if (entityType == null) {
|
85
|
-
result.add(gridValue);
|
86
|
-
} else if (gridValue.entityType.equals(entityType)) {
|
87
|
-
result.add(gridValue);
|
88
|
-
}
|
89
|
-
}
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
return result;
|
94
|
-
}
|
95
|
-
|
96
|
-
public GridValue[] gridValuesInCell(int cell) {
|
97
|
-
ConcurrentHashMap<String, GridValue> cellGridValues = cells.get(cell);
|
98
|
-
|
99
|
-
if (cellGridValues != null) {
|
100
|
-
GridValue[] a = new GridValue[cellGridValues.size()];
|
101
|
-
cellGridValues.values().toArray(a);
|
102
|
-
return a;
|
103
|
-
// return cellGridValues.values();
|
104
|
-
} else {
|
105
|
-
return null;
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
public void updateFromDelta(GridValue[] gridValues) {
|
110
|
-
for (GridValue gridValue : gridValues) {
|
111
|
-
if (gridValue != null) {
|
112
|
-
objectIndex.put(gridValue.id, gridValue);
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
public GridValue[] currentDelta() {
|
118
|
-
GridValue[] a = new GridValue[deltaIndex.size()];
|
119
|
-
deltaIndex.values().toArray(a);
|
120
|
-
deltaIndex.clear();
|
121
|
-
return a;
|
122
|
-
}
|
123
|
-
|
124
|
-
public ArrayList<GridValue> getNeighborsFor(String id, String entityType) {
|
125
|
-
GridValue gridValue = get(id);
|
126
|
-
if (gridValue == null)
|
127
|
-
{
|
128
|
-
return null;
|
129
|
-
}
|
130
|
-
return neighbors(gridValue.x, gridValue.y, entityType);
|
131
|
-
}
|
132
|
-
|
133
|
-
public GridValue get(String id) {
|
134
|
-
return objectIndex.get(id);
|
135
|
-
}
|
136
|
-
|
137
|
-
public void remove(String id) {
|
138
|
-
GridValue indexValue = objectIndex.get(id);
|
139
|
-
if (indexValue != null) {
|
140
|
-
int cell = indexValue.cell;
|
141
|
-
ConcurrentHashMap<String, GridValue> cellGridValues = cells.get(cell);
|
142
|
-
if (cellGridValues != null) {
|
143
|
-
cellGridValues.remove(id);
|
144
|
-
}
|
145
|
-
objectIndex.remove(id);
|
146
|
-
}
|
147
|
-
}
|
148
|
-
|
149
|
-
public Boolean set(String id, float x, float y, float z, String entityType) {
|
150
|
-
GridValue oldValue = objectIndex.get(id);
|
151
|
-
|
152
|
-
if (oldValue != null) {
|
153
|
-
if (oldValue.x == x && oldValue.y == y) {
|
154
|
-
return false;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
|
158
|
-
int cell = hash(x, y);
|
159
|
-
|
160
|
-
|
161
|
-
GridValue gridValue;
|
162
|
-
gridValue = new GridValue(id, cell, x, y, z, entityType);
|
163
|
-
|
164
|
-
if (oldValue == null) {
|
165
|
-
objectIndex.put(id, gridValue);
|
166
|
-
} else {
|
167
|
-
if (oldValue.cell != cell) {
|
168
|
-
ConcurrentHashMap<String, GridValue> cellGridValues = cells.get(oldValue.cell);
|
169
|
-
cellGridValues.remove(id);
|
170
|
-
if (cellGridValues.size() == 0) {
|
171
|
-
cells.remove(oldValue.cell);
|
172
|
-
}
|
173
|
-
|
174
|
-
}
|
175
|
-
objectIndex.replace(id, gridValue);
|
176
|
-
}
|
177
|
-
|
178
|
-
if (!cells.containsKey(cell)) {
|
179
|
-
cells.put(cell, new ConcurrentHashMap<String, GridValue>());
|
180
|
-
}
|
181
|
-
cells.get(cell).put(id, gridValue);
|
182
|
-
|
183
|
-
//deltaIndex.put(id, gridValue);
|
184
|
-
|
185
|
-
return true;
|
186
|
-
}
|
187
|
-
|
188
|
-
public int hash2(float x, float y) {
|
189
|
-
return (int) (Math.floor(x / this.cellSize) + Math.floor(y / this.cellSize) * width);
|
190
|
-
}
|
191
|
-
|
192
|
-
public int hash(float x, float y) {
|
193
|
-
return (int) ((x * this.convFactor)) + (int) ((y * this.convFactor)) * this.width;
|
194
|
-
}
|
195
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<configuration>
|
2
|
-
|
3
|
-
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
4
|
-
<!-- encoders are assigned the type
|
5
|
-
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
6
|
-
<encoder>
|
7
|
-
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
8
|
-
</encoder>
|
9
|
-
</appender>
|
10
|
-
|
11
|
-
<root level="info">
|
12
|
-
<appender-ref ref="STDOUT" />
|
13
|
-
</root>
|
14
|
-
</configuration>
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'base64'
|
2
|
-
module GameMachine
|
3
|
-
module Actor
|
4
|
-
class MonoActor < Base
|
5
|
-
|
6
|
-
def self.images
|
7
|
-
@@images ||= java.util.concurrent.ConcurrentHashMap.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.call_mono(message,image,domain,namespace,klass)
|
11
|
-
thread_id = JRuby.reference(Thread.current).native_thread.id
|
12
|
-
#Mono.attach_current_thread(domain)
|
13
|
-
bytes = message.to_byte_array
|
14
|
-
byte_string = bytes.to_s
|
15
|
-
encoded_bytes = Base64.encode64(byte_string)
|
16
|
-
encoded_bytes_size = encoded_bytes.size
|
17
|
-
actor_id = thread_id.to_s
|
18
|
-
if actor_id == '' or actor_id.nil?
|
19
|
-
puts "actor_id invalid #{actor_id}"
|
20
|
-
return
|
21
|
-
end
|
22
|
-
|
23
|
-
ns_mem_buf = FFI::MemoryPointer.new(:string, namespace.size)
|
24
|
-
ns_mem_buf.put_string(0, namespace)
|
25
|
-
klass_mem_buf = FFI::MemoryPointer.new(:string, klass.size)
|
26
|
-
klass_mem_buf.put_string(0, klass)
|
27
|
-
bytes_mem_buf = FFI::MemoryPointer.new(:string, encoded_bytes_size)
|
28
|
-
bytes_mem_buf.put_string(0, encoded_bytes)
|
29
|
-
mem_buf = FFI::MemoryPointer.new(:string, actor_id.size)
|
30
|
-
mem_buf.put_string(0, actor_id)
|
31
|
-
|
32
|
-
#puts "ENCODED #{encoded_bytes} = #{encoded_bytes_size}"
|
33
|
-
#res = Mono.ftest(@namespace,@klass,actor_id, encoded_bytes, encoded_bytes_size)
|
34
|
-
#puts 'before_on_receive'
|
35
|
-
res = Mono.on_receive2(domain,image,ns_mem_buf,klass_mem_buf,mem_buf, bytes_mem_buf, encoded_bytes_size)
|
36
|
-
#puts 'after_on_receive'
|
37
|
-
#res = Mono.on_receive(@mono_object,bytes.to_s,bytes.size)
|
38
|
-
if res == 0
|
39
|
-
raise "Mono managed code threw exception, restarting actor"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def post_init(*args)
|
44
|
-
@path = args[0]
|
45
|
-
@namespace = args[1]
|
46
|
-
@klass = args[2]
|
47
|
-
@domain = args[3]
|
48
|
-
@image = args[4]
|
49
|
-
end
|
50
|
-
|
51
|
-
def create_mono_object
|
52
|
-
@thread_id = JRuby.reference(Thread.current).native_thread.id
|
53
|
-
if @path.nil? or @namespace.nil? or @klass.nil?
|
54
|
-
raise "Missing post_init args"
|
55
|
-
end
|
56
|
-
Mono.attach_current_thread(@domain)
|
57
|
-
@image = Mono.load_assembly(@domain,@path)
|
58
|
-
#@mono_object = Mono.create_object(image,namespace,klass)
|
59
|
-
#if @mono_object == 0
|
60
|
-
# raise "Mono.create_object failed"
|
61
|
-
#end
|
62
|
-
end
|
63
|
-
|
64
|
-
def ensure_image
|
65
|
-
thread_id = JRuby.reference(Thread.current).native_thread.id
|
66
|
-
image = self.class.images.fetch(thread_id,nil)
|
67
|
-
if image.nil?
|
68
|
-
Mono.attach_current_thread(@domain)
|
69
|
-
image = Mono.load_assembly(@domain,@path)
|
70
|
-
self.class.images[thread_id] = image
|
71
|
-
end
|
72
|
-
image
|
73
|
-
end
|
74
|
-
|
75
|
-
def postStop
|
76
|
-
puts 'postStop'
|
77
|
-
#Mono.destroy_object(@mono_object)
|
78
|
-
end
|
79
|
-
|
80
|
-
def on_receive(message)
|
81
|
-
Mono.attach_current_thread(@domain)
|
82
|
-
|
83
|
-
self.class.call_mono(message,@image,@domain,@namespace,@klass)
|
84
|
-
sender.tell(message,self)
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module GameMachine
|
4
|
-
module AuthHandlers
|
5
|
-
class Base
|
6
|
-
include Singleton
|
7
|
-
extend Forwardable
|
8
|
-
|
9
|
-
def_delegators :@handler, :authorize, :authtoken_for
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
@handler = Application.config.auth_handler.constantize.new
|
13
|
-
end
|
14
|
-
|
15
|
-
def set_handler(handler_name)
|
16
|
-
@handler = handler_name.constantize.new
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'digest/md5'
|
2
|
-
module GameMachine
|
3
|
-
module AuthHandlers
|
4
|
-
class Public
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@sessions = {}
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_user(username,authtoken)
|
11
|
-
@sessions[username] = authtoken
|
12
|
-
end
|
13
|
-
|
14
|
-
def authorize(user,pass)
|
15
|
-
authtoken(user,'public')
|
16
|
-
end
|
17
|
-
|
18
|
-
def authtoken_for(user)
|
19
|
-
if @sessions.has_key?(user)
|
20
|
-
@sessions[user]
|
21
|
-
else
|
22
|
-
@sessions[user] = authtoken(user,'public')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def authtoken(user,pass)
|
29
|
-
Digest::MD5.hexdigest("#{user}#{pass}#{rand(10000)}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
@@ -1,87 +0,0 @@
|
|
1
|
-
module GameMachine
|
2
|
-
module Endpoints
|
3
|
-
class MonoGateway < Actor::Base
|
4
|
-
|
5
|
-
def post_init(*args)
|
6
|
-
@clients = {}
|
7
|
-
@sender = nil
|
8
|
-
@socket = nil
|
9
|
-
@mono_connected = false
|
10
|
-
@last_mono_ping = nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def preStart
|
14
|
-
mgr = JavaLib::Udp.get(getContext.system).getManager
|
15
|
-
inet = JavaLib::InetSocketAddress.new(
|
16
|
-
Application.config.mono_gateway_host,
|
17
|
-
Application.config.mono_gateway_port
|
18
|
-
)
|
19
|
-
mgr.tell( JavaLib::UdpMessage.bind(getSelf,inet), getSelf)
|
20
|
-
end
|
21
|
-
|
22
|
-
def on_receive(message)
|
23
|
-
if message.kind_of?(JavaLib::Udp::Bound)
|
24
|
-
@socket = getSender
|
25
|
-
elsif message.is_a?(MessageLib::Entity)
|
26
|
-
handle_outgoing(message)
|
27
|
-
elsif message.kind_of?(JavaLib::Udp::Received)
|
28
|
-
handle_incoming(message)
|
29
|
-
elsif message == JavaLib::UdpMessage::unbind
|
30
|
-
@socket.tell(message, get_self)
|
31
|
-
elsif message.kind_of?(JavaLib::Udp::Unbound)
|
32
|
-
get_context.stop(get_self)
|
33
|
-
else
|
34
|
-
unhandled(message)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
def handle_outgoing(message)
|
41
|
-
if message.has_destination
|
42
|
-
if @sender
|
43
|
-
byte_string = JavaLib::ByteString.from_array(message.to_byte_array)
|
44
|
-
udp_message = JavaLib::UdpMessage.send(byte_string, @sender)
|
45
|
-
@socket.tell(udp_message, get_self)
|
46
|
-
else
|
47
|
-
GameMachine.logger.error "#{self.class.name} cannot send outgoing message (no sender) "
|
48
|
-
end
|
49
|
-
else
|
50
|
-
GameMachine.logger.error "#{self.class.name} destination missing (outgoing)"
|
51
|
-
end
|
52
|
-
rescue Exception => e
|
53
|
-
GameMachine.logger.error "#{self.class.name} #{e.to_s}"
|
54
|
-
end
|
55
|
-
|
56
|
-
def handle_incoming(message)
|
57
|
-
@sender = message.sender
|
58
|
-
entity = MessageLib::Entity.parse_from(message.data.to_array)
|
59
|
-
if entity.id == 'ping'
|
60
|
-
unless @mono_connected
|
61
|
-
GameMachine.logger.info "Mono server connected"
|
62
|
-
end
|
63
|
-
@mono_connected = true
|
64
|
-
@last_mono_ping = Time.now.to_i
|
65
|
-
echo(message)
|
66
|
-
elsif entity.has_destination
|
67
|
-
destination = entity.destination.sub(/^\//,'')
|
68
|
-
destination = destination.gsub('/','::')
|
69
|
-
entity.set_destination(nil)
|
70
|
-
GameMachine.logger.info "#{self.class.name} incoming to #{destination}"
|
71
|
-
Actor::Base.find(destination).tell(entity,get_self)
|
72
|
-
else
|
73
|
-
GameMachine.logger.error "#{self.class.name} destination missing (incoming)"
|
74
|
-
end
|
75
|
-
rescue Exception => e
|
76
|
-
GameMachine.logger.error "#{self.class.name} #{e.to_s}"
|
77
|
-
end
|
78
|
-
|
79
|
-
def echo(message)
|
80
|
-
byte_string = JavaLib::ByteString.from_array(message.data.to_array)
|
81
|
-
udp_message = JavaLib::UdpMessage.send(byte_string, message.sender)
|
82
|
-
@socket.tell(udp_message,get_self)
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|