Gridarta Editor
AtrinikServerActions.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.var.atrinik.actions;
21 
22 import java.io.ByteArrayOutputStream;
23 import java.io.IOException;
24 import java.io.OutputStream;
25 import java.net.Socket;
31 import org.jetbrains.annotations.NotNull;
32 
38 public class AtrinikServerActions extends AbstractServerActions<GameObject, MapArchObject, Archetype> {
39 
43  private static final int SERVER_CMD_CONTROL = 0;
44 
48  @NotNull
49  private static final String APPLICATION_NAME_IDENTIFIER = "gridarta";
50 
54  @NotNull
55  private static final String CHARSET_NAME = "US-ASCII";
56 
60  private static final int CMD_CONTROL_MAP = 1;
61 
65  private static final int CMD_CONTROL_PLAYER = 2;
66 
70  private static final int CMD_CONTROL_MAP_RESET = 1;
71 
75  private static final int CMD_CONTROL_PLAYER_TELEPORT = 1;
76 
82  super(fileControl);
83  }
84 
90  private void sendPacket(@NotNull final ByteArrayOutputStream stream) throws IOException {
91  final byte[] packet = stream.toByteArray();
92  packet[0] = (byte) ((packet.length - 2) >> 8);
93  packet[1] = (byte) (packet.length - 2);
94  try {
95  try (Socket socket = new Socket("127.0.0.1", 13327)) {
96  final OutputStream outputStream = socket.getOutputStream();
97  outputStream.write(packet);
98  socket.shutdownOutput();
99  }
100  } catch (final IOException ex) {
101  throw new IOException("127.0.0.1:13327: " + ex.getMessage(), ex);
102  }
103  }
104 
105  @Override
106  protected void resetMap(@NotNull final String mapPath) throws IOException {
107  final ByteArrayOutputStream tmp = new ByteArrayOutputStream();
108  tmp.write(0);
109  tmp.write(0);
110  tmp.write(SERVER_CMD_CONTROL);
111  tmp.write(APPLICATION_NAME_IDENTIFIER.getBytes(CHARSET_NAME));
112  tmp.write(0); // termination of application name identifier
113  tmp.write(CMD_CONTROL_MAP);
114  tmp.write(CMD_CONTROL_MAP_RESET);
115  tmp.write(mapPath.getBytes(CHARSET_NAME));
116  tmp.write(0);
117  sendPacket(tmp);
118  }
119 
120  @Override
121  protected void teleportCharacterToMap(@NotNull final String mapPath, final int mapX, final int mapY) throws IOException {
122  final ByteArrayOutputStream tmp = new ByteArrayOutputStream();
123  tmp.write(0);
124  tmp.write(0);
125  tmp.write(SERVER_CMD_CONTROL);
126  tmp.write(APPLICATION_NAME_IDENTIFIER.getBytes(CHARSET_NAME));
127  tmp.write(0); // termination of application name identifier
128  tmp.write(CMD_CONTROL_PLAYER);
129  tmp.write(CMD_CONTROL_PLAYER_TELEPORT);
130  tmp.write(0); // empty player name
131  tmp.write(mapPath.getBytes(CHARSET_NAME));
132  tmp.write(0);
133  tmp.write(mapX >> 8);
134  tmp.write(mapX);
135  tmp.write(mapY >> 8);
136  tmp.write(mapY);
137  sendPacket(tmp);
138  }
139 
140 }
net.sf.gridarta.model.mapmanager
Definition: AbstractMapManager.java:20
net.sf.gridarta.actions.AbstractServerActions
Actions that require a connection to a game server.
Definition: AbstractServerActions.java:44
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.APPLICATION_NAME_IDENTIFIER
static final String APPLICATION_NAME_IDENTIFIER
The name of the application requesting control.
Definition: AtrinikServerActions.java:49
tools
daimonin editor devlib README txt This directory contains some files and libraries for development tools
Definition: README.txt:3
net.sf.gridarta
Base package of all Gridarta classes.
files
Standard Edition Runtime Environment README Import and export control rules on cryptographic software vary from country to country The Java Cryptography Java provides two different sets of cryptographic policy files
Definition: README.txt:26
that
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from that
Definition: Developer_README.txt:22
directory
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root directory
Definition: Developer_README.txt:45
net.sf
net.sf.gridarta.model.mapmanager.FileControl
Definition: FileControl.java:30
http
daimonin editor devlib README txt This directory contains some files and libraries for development similar to indent for C http
Definition: README.txt:16
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.resetMap
void resetMap(@NotNull final String mapPath)
Resets a map identified by the given map path.
Definition: AtrinikServerActions.java:106
net.sf.gridarta.var
Extension
Standard Edition Runtime Environment README Import and export control rules on cryptographic software vary from country to country The Java Cryptography Extension(JCE) architecture allows flexible cryptographic key strength to be configured via the jurisdiction policy files which are referenced by the "crypto.policy" security property in the< java-home >/conf/security/java.security file. By default
net.sf.gridarta.var.atrinik.model.archetype.Archetype
Implements Atrinik archetypes.
Definition: Archetype.java:30
so
Daimonin Editor like your to identify any bugs in the that are reported by the debuggers If a problem does exist you can forward the error message that appears in your debugging console you must have built the editor with debug flag To do so
Definition: ReadMe.txt:19
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions
The AbstractServerActions implementation for connecting to an Atrinik server.
Definition: AtrinikServerActions.java:38
Java
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of Java
Definition: Developer_README.txt:34
net
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.SERVER_CMD_CONTROL
static final int SERVER_CMD_CONTROL
Command type.
Definition: AtrinikServerActions.java:43
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.CMD_CONTROL_PLAYER_TELEPORT
static final int CMD_CONTROL_PLAYER_TELEPORT
Control command sub-type: teleport character to map.
Definition: AtrinikServerActions.java:75
currently
daimonin editor devlib README txt This directory contains some files and libraries for development currently
Definition: README.txt:10
net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject
MapArchObject contains the specific meta data about a map that is stored in the map-arch,...
Definition: MapArchObject.java:39
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.sendPacket
void sendPacket(@NotNull final ByteArrayOutputStream stream)
Send a bytes packet to the Atrinik server instance.
Definition: AtrinikServerActions.java:90
net.sf.gridarta.var.atrinik
Main package of Gridarta4Atrinik, contains all classes specific to the Atrinik version of the Gridart...
net.sf.gridarta.var.atrinik.model.gameobject.GameObject
Handles the Atrinik GameObjects.
Definition: GameObject.java:44
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.CMD_CONTROL_MAP
static final int CMD_CONTROL_MAP
Control command type: control a map.
Definition: AtrinikServerActions.java:60
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.teleportCharacterToMap
void teleportCharacterToMap(@NotNull final String mapPath, final int mapX, final int mapY)
Teleports the character to the given map path.
Definition: AtrinikServerActions.java:121
net.sf.gridarta.var.atrinik.model.maparchobject
Definition: DefaultMapArchObjectFactory.java:20
Java
Java(TM) Cryptography Extension Policy Files for the Java(TM) Platform
system
daimonin editor devlib README txt This directory contains some files and libraries for development similar to indent for C and because many Java developers already have these libraries somewhere else on their system
Definition: README.txt:18
net.sf.gridarta.model
past
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the past
Definition: Developer_README.txt:37
net.sf.gridarta.var.atrinik.model
editor
Daimonin Editor like your to identify any bugs in the editor
Definition: ReadMe.txt:5
net.sf.gridarta.actions
Definition: AbstractServerActions.java:20
subdirectory
Standard Edition Runtime Environment README Import and export control rules on cryptographic software vary from country to country The Java Cryptography Java provides two different sets of cryptographic policy and subdirectories can be added edited removed to reflect your import or export control product requirements Within a subdirectory
Definition: README.txt:30
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.CMD_CONTROL_PLAYER
static final int CMD_CONTROL_PLAYER
Control command type: control a player.
Definition: AtrinikServerActions.java:65
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.CHARSET_NAME
static final String CHARSET_NAME
The charset name for encoding strings in the protocol.
Definition: AtrinikServerActions.java:55
net.sf.gridarta.var.atrinik.model.gameobject
Handles the Atrinik variants of GameObjects and Archetypes.
Definition: DefaultGameObjectFactory.java:20
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.AtrinikServerActions
AtrinikServerActions(@NotNull final FileControl< GameObject, MapArchObject, Archetype > fileControl)
Creates a new instance.
Definition: AtrinikServerActions.java:81
net.sf.gridarta.actions.AbstractServerActions.fileControl
final FileControl< G, A, R > fileControl
The file control for saving maps.
Definition: AbstractServerActions.java:56
net.sf.gridarta.var.atrinik.model.archetype
Definition: Archetype.java:20
Debugging
Daimonin Editor Debugging
Definition: ReadMe.txt:4
net.sf.gridarta.var.atrinik.actions.AtrinikServerActions.CMD_CONTROL_MAP_RESET
static final int CMD_CONTROL_MAP_RESET
Control command sub-type: reset a map.
Definition: AtrinikServerActions.java:70
it
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it
Definition: Developer_README.txt:76