de.farafin.snEADy.inOut
Class C_RecordFileReader

java.lang.Object
  extended by de.farafin.snEADy.inOut.C_RecordFileReader
All Implemented Interfaces:
I_Constants

public class C_RecordFileReader
extends java.lang.Object
implements I_Constants

reads a record file:

file scheme:
for each gameCycle:
what is stored (consumtion)
- Number bytes (2Byte)
- Nnumber of playfield changes (1Byte)
- Playfield changes (3 Byte each)
...
- Player Nr and status changes (1 Byte)
= Player Number (4 bit)
+ speed changed? (1 bit)
+ length changed? (1 bit)
+ Points changed? (1 bit)
+ Status changed? (1 bit)
- playerdata (max 7 Byte)
= new speed (1 Byte) [only if change bit is 1]
+ new Length (2 Byte) [only if change bit is 1]
+ new points (2 Byte) [only if change bit is 1]
+ new Status (1 Byte) [only if change bit is 1]
+ head move direction (1 Byte)
- if player Nr == 15: new Exit Time (8 Byte) + new SDTime (8 Byte) = 17 Byte

Author:
roland, lars

Field Summary
private  int actPos
          Position in the buffer
private  java.io.File binFile
          Comment for logFile
private  byte[] buffer
          the buffer of data
private  java.lang.String header
          Comment for header
private  int headerLength
          Comment for headerLength
private  int startPos
          Comment for startPos
 
Fields inherited from interface de.farafin.snEADy.communication.I_Constants
analyse_ms, auto_grow_delay, auto_slowdown_delay, autogamespeed, closemonitor, damage_length_grow, damage_points_radius, DEBUG, delplayer, easy_points, ejectreplay, emergencyPause, exit_time, FACE_EAST, FACE_NORTH, FACE_SOUTH, FACE_WEST, game_end, goody_length_occ, goody_length_value, goody_points_occ, goody_points_value, goody_shorter_occ, goody_shorter_value, goody_slowdown_occ, goody_speed_occ, IN_ACTION, IN_ERROR_EXC, IN_ERROR_INIT, IN_ERROR_SPACE, IN_ERROR_TIME, IN_EXIT, IN_HEAVEN, init_length, init_move_delay, kill, kill_point_goodies, kill_points_radius, loaddummy, loadhuman, loadlevel, loadplayer, loadscript, logging, max_goody_occ_delay, MAX_HUMAN_PLAYERS, max_mem_check_delay, max_move_delay, max_player_mem, MAX_PLAYERS, max_thinking_ms, memkill, min_cycle_ms, min_move_delay, MOVE_EAST, MOVE_NORTH, MOVE_SOUTH, MOVE_WEST, openmonitor, overalldelay, pause, player_controlling, print_calc_ms, print_parameter, print_player_mem, print_playfield, quit, record, recordname, replay, replay_reverse, replay_stepwidth, replay_stepwise, run, set, show_subcycles, start, stop, suddend_time, survival_points, timekill, tolerance_ms, TURN_LEFT, TURN_NONE, TURN_RIGHT
 
Constructor Summary
C_RecordFileReader(java.lang.String fileName)
           
C_RecordFileReader(java.lang.String root, java.lang.String fileName)
           
 
Method Summary
 java.lang.String getFileName()
           
 boolean isFinished()
           
 boolean isStart()
           
 byte[] readGameCycle(byte[] buf, boolean reverse)
          gets a game cycle data block
 java.lang.String[] readHeader()
          reeads the haader of the file
 void restart()
          next line is set to 0
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

binFile

private java.io.File binFile
Comment for logFile


buffer

private byte[] buffer
the buffer of data


actPos

private int actPos
Position in the buffer


headerLength

private int headerLength
Comment for headerLength


startPos

private int startPos
Comment for startPos


header

private java.lang.String header
Comment for header

Constructor Detail

C_RecordFileReader

public C_RecordFileReader(java.lang.String root,
                          java.lang.String fileName)
                   throws java.io.FileNotFoundException
Parameters:
root -
fileName -
Throws:
java.io.FileNotFoundException

C_RecordFileReader

public C_RecordFileReader(java.lang.String fileName)
                   throws java.io.FileNotFoundException
Parameters:
fileName -
Throws:
java.io.FileNotFoundException
Method Detail

readHeader

public java.lang.String[] readHeader()
reeads the haader of the file

Returns:
the lines the header constists of

readGameCycle

public byte[] readGameCycle(byte[] buf,
                            boolean reverse)
gets a game cycle data block

Parameters:
buf - The buffer where the data should be stored in. If it is to small, there will be a new one created and given back.
if - the game should be read reveresed or not
Returns:
the buffer. if buf was too small, it will be a new instance returned

isFinished

public boolean isFinished()
Returns:
if all lines were read

isStart

public boolean isStart()
Returns:
if all lines were read

restart

public void restart()
next line is set to 0


getFileName

public java.lang.String getFileName()
Returns:
v