Importing SVN archives - Trunk

This commit is contained in:
Emmanuel BENOîT 2018-10-23 09:43:42 +02:00
parent fc4c6bd340
commit ff53af6668
507 changed files with 8866 additions and 2450 deletions

View file

@ -4,12 +4,12 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-accounts</artifactId>
<name>Legacy Worlds account management</name>
<version>5.99.1</version>
<version>5.99.2</version>
<description>This package contains the beans responsible for managing accounts, including registration, inactivity checks, bans and authentication.</description>
</project>

View file

@ -4,7 +4,7 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<dependencies>
@ -20,6 +20,6 @@
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-bt</artifactId>
<version>5.99.1</version>
<version>5.99.2</version>
<name>Legacy Worlds bug tracking system</name>
</project>

View file

@ -28,6 +28,7 @@ public class EmpireSummaryBean
private final RowMapper< DebugInformation > mMainInfo;
private final RowMapper< ResearchInformation > mResearch;
private final RowMapper< TechnologyInformation > mTechnology;
private final RowMapper< PlanetInformation > mPlanet;
private final RowMapper< QueueItemInformation > mQueueItem;
private final RowMapper< BuildingsInformation > mBuildings;
@ -42,7 +43,8 @@ public class EmpireSummaryBean
AccountInformation.class , AllianceInformation.class , BuildingsInformation.class ,
DebugInformation.class , EmpireInformation.class , FleetInformation.class , MovementInformation.class ,
PlanetInformation.class , QueueInformation.class , QueueItemInformation.class ,
ResearchInformation.class , ShipsInformation.class , SystemInformation.class
ResearchInformation.class , TechnologyInformation.class , ShipsInformation.class ,
SystemInformation.class
} );
this.mMainInfo = new RowMapper< DebugInformation >( ) {
@ -83,13 +85,23 @@ public class EmpireSummaryBean
throws SQLException
{
ResearchInformation ri = new ResearchInformation( );
ri.setId( rs.getInt( "line_id" ) );
ri.setCurrentLevel( rs.getInt( "level" ) );
ri.setLevelName( rs.getString( "name" ) );
ri.setName( rs.getString( "name" ) );
ri.setAccumulated( rs.getDouble( "accumulated" ) );
ri.setPriority( rs.getInt( "priority" ) );
return ri;
}
};
this.mTechnology = new RowMapper< TechnologyInformation >( ) {
@Override
public TechnologyInformation mapRow( ResultSet rs , int rowNum )
throws SQLException
{
TechnologyInformation ti = new TechnologyInformation( );
ti.setName( rs.getString( "name" ) );
ti.setImplemented( rs.getBoolean( "implemented" ) );
return ti;
}
};
this.mPlanet = new RowMapper< PlanetInformation >( ) {
@Override
public PlanetInformation mapRow( ResultSet rs , int rowNum )
@ -199,9 +211,10 @@ public class EmpireSummaryBean
DebugInformation di = this.dTemplate.queryForObject( sql , this.mMainInfo , empireId );
sql = "SELECT * FROM bugs.dump_research_view WHERE empire_id = ?";
for ( ResearchInformation ri : this.dTemplate.query( sql , this.mResearch , empireId ) ) {
di.getResearch( ).add( ri );
}
di.getResearch( ).addAll( this.dTemplate.query( sql , this.mResearch , empireId ) );
sql = "SELECT * FROM bugs.dump_technologies_view WHERE empire_id = ?";
di.getTechnologies( ).addAll( this.dTemplate.query( sql , this.mTechnology , empireId ) );
sql = "SELECT * FROM bugs.dump_planets_view WHERE empire_id = ?";
Map< Integer , PlanetInformation > planets = new HashMap< Integer , PlanetInformation >( );

View file

@ -15,26 +15,29 @@ public class DebugInformation
implements Serializable
{
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;
@XStreamAsAttribute
@XStreamAlias( "dump-version" )
private int version = 1;
private final int version = 2;
private SystemInformation system = new SystemInformation( );
private final SystemInformation system = new SystemInformation( );
private AccountInformation account = new AccountInformation( );
private final AccountInformation account = new AccountInformation( );
private EmpireInformation empire = new EmpireInformation( );
private final EmpireInformation empire = new EmpireInformation( );
@XStreamAlias( "research" )
private List< ResearchInformation > research = new LinkedList< ResearchInformation >( );
private final List< ResearchInformation > research = new LinkedList< ResearchInformation >( );
@XStreamAlias( "technologies" )
private final List< TechnologyInformation > technologies = new LinkedList< TechnologyInformation >( );
@XStreamAlias( "planets" )
private List< PlanetInformation > planets = new LinkedList< PlanetInformation >( );
private final List< PlanetInformation > planets = new LinkedList< PlanetInformation >( );
@XStreamAlias( "fleets" )
private List< FleetInformation > fleets = new LinkedList< FleetInformation >( );
private final List< FleetInformation > fleets = new LinkedList< FleetInformation >( );
public int getVersion( )
@ -67,6 +70,12 @@ public class DebugInformation
}
public List< TechnologyInformation > getTechnologies( )
{
return technologies;
}
public List< PlanetInformation > getPlanets( )
{
return planets;
@ -78,4 +87,4 @@ public class DebugInformation
return fleets;
}
}
}

View file

@ -8,64 +8,34 @@ import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
@XStreamAlias( "research-line" )
@XStreamAlias( "research-topic" )
public class ResearchInformation
implements Serializable
{
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;
@XStreamAsAttribute
@XStreamAlias( "line")
private int id;
@XStreamAsAttribute
@XStreamAlias( "level")
private int currentLevel;
private String name;
@XStreamAsAttribute
@XStreamAlias( "name")
private String levelName;
@XStreamAsAttribute
@XStreamAlias( "accumulated-points")
@XStreamAlias( "accumulated-points" )
private double accumulated;
@XStreamAsAttribute
private int priority;
public int getId( )
public String getName( )
{
return id;
return name;
}
public void setId( int id )
public void setName( String name )
{
this.id = id;
}
public int getCurrentLevel( )
{
return currentLevel;
}
public void setCurrentLevel( int currentLevel )
{
this.currentLevel = currentLevel;
}
public String getLevelName( )
{
return levelName;
}
public void setLevelName( String levelName )
{
this.levelName = levelName;
this.name = name;
}
@ -80,4 +50,16 @@ public class ResearchInformation
this.accumulated = accumulated;
}
public int getPriority( )
{
return priority;
}
public void setPriority( int priority )
{
this.priority = priority;
}
}

View file

@ -0,0 +1,48 @@
package com.deepclone.lw.beans.bt.esdata;
import java.io.Serializable;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
@XStreamAlias( "technology" )
public class TechnologyInformation
implements Serializable
{
private static final long serialVersionUID = 1L;
@XStreamAsAttribute
private String name;
@XStreamAsAttribute
private boolean implemented;
public String getName( )
{
return name;
}
public void setName( String name )
{
this.name = name;
}
public boolean isImplemented( )
{
return implemented;
}
public void setImplemented( boolean implemented )
{
this.implemented = implemented;
}
}

View file

@ -4,12 +4,12 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-eventlog</artifactId>
<version>5.99.1</version>
<version>5.99.2</version>
<name>Legacy Worlds event log</name>
<description>This package is responsible for all logging in Legacy Worlds through three different beans (system event logger, admin event logger and user event logger).</description>
</project>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View file

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>legacyworlds-server-beans-events</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,6 @@
#Sun Apr 03 09:36:59 CEST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,9 @@
#Sun Apr 03 09:36:59 CEST 2011
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
includeModules=false
resolveWorkspaceProjects=true
resourceFilterGoals=process-resources resources\:testResources
skipCompilerPlugin=true
version=1

View file

@ -0,0 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-events</artifactId>
<version>5.99.2</version>
<name>Game events</name>
<description>This module contains components which manage game events.</description>
</project>

View file

@ -4,13 +4,13 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-i18n</artifactId>
<name>Legacy Worlds internationalisation</name>
<version>5.99.1</version>
<version>5.99.2</version>
<description>This package defines the two beans which control server-side internationalised text management.</description>
</project>

View file

@ -6,6 +6,7 @@ import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import com.deepclone.lw.interfaces.i18n.LanguageTranslator;
import com.deepclone.lw.interfaces.i18n.Translator;
import com.deepclone.lw.interfaces.i18n.UnknownLanguageException;
import com.deepclone.lw.interfaces.i18n.UnknownStringException;
@ -21,6 +22,67 @@ import com.deepclone.lw.interfaces.i18n.UnknownStringException;
public class TranslatorBean
implements Translator
{
/**
* Implementation of a language-specific translator.
*/
private static class LanguageTranslatorImpl
implements LanguageTranslator
{
/** Language used by the translator */
private final String language;
/** Translations store */
private final I18NData data;
LanguageTranslatorImpl( String language , TranslatorBean translator )
{
this.language = language;
this.data = translator.data;
}
/* Documentation in LanguageTranslator interface */
@Override
public String getLanguage( )
{
return this.language;
}
/* Documentation in LanguageTranslator interface */
@Override
public String getLanguageName( )
{
this.data.readLock( ).lock( );
try {
return this.data.getLanguageName( language );
} finally {
this.data.readLock( ).unlock( );
}
}
/* Documentation in LanguageTranslator interface */
@Override
public String translate( String string )
throws UnknownStringException
{
this.data.readLock( ).lock( );
try {
if ( !this.data.hasString( string ) ) {
throw new UnknownStringException( string );
}
return this.data.getTranslation( language , string );
} finally {
this.data.readLock( ).unlock( );
}
}
}
/** Translations store */
private I18NData data;
@ -119,4 +181,21 @@ public class TranslatorBean
}
}
/* Documentation in Translator interface */
@Override
public LanguageTranslator getLanguageTranslator( String language )
throws UnknownLanguageException
{
this.data.readLock( ).lock( );
try {
if ( !this.data.isLanguageComplete( language ) ) {
throw new UnknownLanguageException( language );
}
return new LanguageTranslatorImpl( language , this );
} finally {
this.data.readLock( ).unlock( );
}
}
}

View file

@ -4,12 +4,12 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-mailer</artifactId>
<version>5.99.1</version>
<version>5.99.2</version>
<name>Legacy Worlds mailer</name>
<description>
This package contains the mailer component, which uses LW's i18n system and Spring's mail sending interfaces.

View file

@ -4,12 +4,12 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-naming</artifactId>
<version>5.99.1</version>
<version>5.99.2</version>
<name>Legacy Worlds object naming system</name>
<description>This module contains the beans responsible for managing the names of the various objects (players and planets).</description>
</project>

View file

@ -3,11 +3,11 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-simple</artifactId>
<version>5.99.1</version>
<version>5.99.2</version>
<name>Legacy Worlds simple game</name>
<description>This module contains code that corresponds to a simple "placeholder" game. This code should become obsolete over time, as it is being replaced with actual LWB6 code, until the module can finally be removed.</description>
</project>

View file

@ -4,9 +4,7 @@ package com.deepclone.lw.beans.empire;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
@ -20,8 +18,6 @@ import com.deepclone.lw.cmd.player.gdata.NameIdPair;
import com.deepclone.lw.cmd.player.gdata.PlanetListData;
import com.deepclone.lw.cmd.player.gdata.empire.OverviewData;
import com.deepclone.lw.interfaces.game.EmpireDAO;
import com.deepclone.lw.sqld.game.EmpireTechLine;
import com.deepclone.lw.sqld.game.EmpireTechnology;
import com.deepclone.lw.sqld.game.GeneralInformation;
import com.deepclone.lw.utils.StoredProc;
@ -31,7 +27,6 @@ public class EmpireDAOBean
implements EmpireDAO
{
private SimpleJdbcTemplate dTemplate;
private StoredProc fImplementTech;
private StoredProc fAddEmpEnemy;
private StoredProc fAddAllEnemy;
private StoredProc fRemoveEmpEnemy;
@ -40,16 +35,36 @@ public class EmpireDAOBean
private final PlanetListMapper mPlanetList = new PlanetListMapper( );
private final RowMapper< GeneralInformation > mEmpireInfo;
public EmpireDAOBean( )
{
this.mEmpireInfo = new RowMapper< GeneralInformation >( ) {
@Override
public GeneralInformation mapRow( ResultSet rs , int rowNum )
throws SQLException
{
String st = rs.getString( "status" );
Character status = ( st == null ) ? null : st.charAt( 0 );
String name = rs.getString( "name" );
String tag = rs.getString( "alliance" );
String language = rs.getString( "language" );
long cash = rs.getLong( "cash" );
long nextTick = rs.getLong( "game_time" );
int accountId = rs.getInt( "account_id" );
return new GeneralInformation( status , name , tag , language , cash , nextTick , accountId );
}
};
}
@Autowired( required = true )
public void setDataSource( DataSource dataSource )
{
this.dTemplate = new SimpleJdbcTemplate( dataSource );
this.fImplementTech = new StoredProc( dataSource , "emp" , "implement_tech" );
this.fImplementTech.addParameter( "empire_id" , Types.INTEGER );
this.fImplementTech.addParameter( "line_id" , Types.INTEGER );
this.fAddEmpEnemy = new StoredProc( dataSource , "emp" , "add_enemy_empire" );
this.fAddEmpEnemy.addParameter( "empire_id" , Types.INTEGER );
this.fAddEmpEnemy.addParameter( "enemy_name" , Types.VARCHAR );
@ -79,19 +94,8 @@ public class EmpireDAOBean
public GeneralInformation getInformation( int empireId )
{
String sql = "SELECT * FROM emp.general_information WHERE id = ?";
RowMapper< GeneralInformation > mapper = new RowMapper< GeneralInformation >( ) {
@Override
public GeneralInformation mapRow( ResultSet rs , int rowNum )
throws SQLException
{
String st = rs.getString( "status" );
Character status = ( st == null ) ? null : st.charAt( 0 );
return new GeneralInformation( status , rs.getString( "name" ) , rs.getString( "alliance" ) , rs
.getLong( "cash" ) , rs.getLong( "game_time" ) , rs.getInt( "account_id" ) );
}
};
try {
return this.dTemplate.queryForObject( sql , mapper , empireId );
return this.dTemplate.queryForObject( sql , this.mEmpireInfo , empireId );
} catch ( EmptyResultDataAccessException e ) {
return null;
}
@ -156,65 +160,6 @@ public class EmpireDAOBean
}
@Override
public List< EmpireTechLine > getTechnology( int empireId )
{
String sql = "SELECT * FROM emp.tech_lines_view WHERE empire = ?";
RowMapper< EmpireTechLine > lineMapper = new RowMapper< EmpireTechLine >( ) {
@Override
public EmpireTechLine mapRow( ResultSet rs , int rowNum )
throws SQLException
{
EmpireTechLine etl = new EmpireTechLine( );
etl.setId( rs.getInt( "tech_line" ) );
etl.setName( rs.getString( "name" ) );
etl.setDescription( rs.getString( "description" ) );
return etl;
}
};
List< EmpireTechLine > lines = this.dTemplate.query( sql , lineMapper , empireId );
if ( lines.isEmpty( ) ) {
return lines;
}
Map< Integer , EmpireTechLine > linesById = new HashMap< Integer , EmpireTechLine >( );
for ( EmpireTechLine etl : lines ) {
linesById.put( etl.getId( ) , etl );
}
sql = "SELECT * FROM emp.technologies_view WHERE empire = ?";
RowMapper< EmpireTechnology > techMapper = new RowMapper< EmpireTechnology >( ) {
@Override
public EmpireTechnology mapRow( ResultSet rs , int rowNum )
throws SQLException
{
EmpireTechnology et = new EmpireTechnology( );
et.setLine( rs.getInt( "tech_line" ) );
et.setName( rs.getString( "name" ) );
et.setDescription( rs.getString( "description" ) );
et.setImplemented( rs.getBoolean( "implemented" ) );
et.setProgress( (int) rs.getDouble( "progress" ) );
et.setCost( rs.getInt( "cost" ) );
return et;
}
};
for ( EmpireTechnology et : this.dTemplate.query( sql , techMapper , empireId ) ) {
linesById.get( et.getLine( ) ).addTechnology( et );
}
return lines;
}
@Override
public void implementTechnology( int empireId , int lineId )
{
this.fImplementTech.execute( empireId , lineId );
}
@Override
public List< PlanetListData > getPlanetList( int empireId )
{

View file

@ -18,19 +18,18 @@ import com.deepclone.lw.cmd.player.gdata.NameIdPair;
import com.deepclone.lw.cmd.player.gdata.PlanetListData;
import com.deepclone.lw.cmd.player.gdata.battles.BattleListEntry;
import com.deepclone.lw.cmd.player.gdata.empire.OverviewData;
import com.deepclone.lw.cmd.player.gdata.empire.ResearchLineData;
import com.deepclone.lw.cmd.player.gdata.empire.TechnologyData;
import com.deepclone.lw.interfaces.acm.UsersDAO;
import com.deepclone.lw.interfaces.game.BattlesCache;
import com.deepclone.lw.interfaces.game.BattlesDAO;
import com.deepclone.lw.interfaces.game.EmpireDAO;
import com.deepclone.lw.interfaces.game.EmpireManagement;
import com.deepclone.lw.interfaces.i18n.LanguageTranslator;
import com.deepclone.lw.interfaces.i18n.Translator;
import com.deepclone.lw.interfaces.i18n.UnknownLanguageException;
import com.deepclone.lw.interfaces.naming.NamingDAO;
import com.deepclone.lw.interfaces.prefs.AccountPreferences;
import com.deepclone.lw.interfaces.prefs.PreferencesDAO;
import com.deepclone.lw.sqld.accounts.Account;
import com.deepclone.lw.sqld.game.EmpireTechLine;
import com.deepclone.lw.sqld.game.EmpireTechnology;
import com.deepclone.lw.sqld.game.GeneralInformation;
import com.deepclone.lw.sqld.game.battle.BattleListRecord;
import com.deepclone.lw.utils.EmailAddress;
@ -46,6 +45,7 @@ public class EmpireManagementBean
private EmpireDAO empireDao;
private PreferencesDAO prefsDao;
private BattlesDAO battlesDao;
private Translator translator;
@Autowired( required = true )
@ -83,6 +83,13 @@ public class EmpireManagementBean
}
@Autowired( required = true )
public void setI18NManager( Translator translator )
{
this.translator = translator;
}
@Override
public Integer getEmpireId( EmailAddress address )
{
@ -108,29 +115,22 @@ public class EmpireManagementBean
}
@Override
public LanguageTranslator getTranslator( int empireId )
{
GeneralInformation generalInformation = this.empireDao.getInformation( empireId );
try {
return this.translator.getLanguageTranslator( generalInformation.getLanguage( ) );
} catch ( UnknownLanguageException e ) {
throw new RuntimeException( "account for empire " + empireId + " is using an unsupported language" , e );
}
}
@Override
public EmpireResponse getOverview( int empireId )
{
OverviewData overview = this.empireDao.getOverview( empireId );
List< ResearchLineData > research = new LinkedList< ResearchLineData >( );
for ( EmpireTechLine etl : this.empireDao.getTechnology( empireId ) ) {
List< TechnologyData > implemented = new LinkedList< TechnologyData >( );
TechnologyData current = null;
for ( EmpireTechnology et : etl.getTechnologies( ) ) {
if ( et.isImplemented( ) ) {
implemented.add( new TechnologyData( et.getName( ) , et.getDescription( ) ) );
} else if ( et.getProgress( ) == 100 ) {
current = new TechnologyData( et.getName( ) , et.getDescription( ) , 100 , et.getCost( ) );
} else {
current = new TechnologyData( et.getName( ) , et.getDescription( ) , et.getProgress( ) );
}
}
research.add( new ResearchLineData( etl.getId( ) , etl.getName( ) , etl.getDescription( ) , implemented ,
current ) );
}
List< BattleListEntry > battles = new LinkedList< BattleListEntry >( );
for ( BattleListRecord record : this.battlesDao.getBattles( empireId ) ) {
@ -150,15 +150,7 @@ public class EmpireManagementBean
battles.add( entry );
}
return new EmpireResponse( this.getGeneralInformation( empireId ) , overview , research , battles );
}
@Override
public EmpireResponse implementTechnology( int empireId , int techId )
{
this.empireDao.implementTechnology( empireId , techId );
return this.getOverview( empireId );
return new EmpireResponse( this.getGeneralInformation( empireId ) , overview , battles );
}

View file

@ -1,138 +0,0 @@
package com.deepclone.lw.beans.updates;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
import com.deepclone.lw.cmd.admin.logs.LogLevel;
import com.deepclone.lw.interfaces.eventlog.Logger;
import com.deepclone.lw.interfaces.eventlog.SystemLogger;
import com.deepclone.lw.interfaces.game.UpdatesDAO;
import com.deepclone.lw.interfaces.sys.MaintenanceStatusException;
import com.deepclone.lw.interfaces.sys.SystemStatus;
import com.deepclone.lw.interfaces.sys.TickStatusException;
import com.deepclone.lw.interfaces.sys.Ticker;
import com.deepclone.lw.interfaces.sys.Ticker.Frequency;
public class GameUpdateBean
implements InitializingBean , Runnable
{
private Ticker ticker;
private SystemStatus systemStatus;
private SystemLogger logger;
private TransactionTemplate tTemplate;
private UpdatesDAO updatesDao;
@Autowired( required = true )
public void setTicker( Ticker ticker )
{
this.ticker = ticker;
}
@Autowired( required = true )
public void setSystemStatus( SystemStatus systemStatus )
{
this.systemStatus = systemStatus;
}
@Autowired( required = true )
public void setLogger( Logger logger )
{
this.logger = logger.getSystemLogger( "GameUpdate" );
}
@Autowired( required = true )
public void setTransactionManager( PlatformTransactionManager transactionManager )
{
this.tTemplate = new TransactionTemplate( transactionManager );
}
@Autowired( required = true )
public void setUpdatesDAO( UpdatesDAO updatesDao )
{
this.updatesDao = updatesDao;
}
@Override
public void afterPropertiesSet( )
{
try {
this.endPreviousTick( );
} catch ( MaintenanceStatusException e ) {
// Do nothing
}
this.ticker.registerTask( Frequency.MINUTE , "Game update" , this );
}
@Override
public void run( )
{
// Attempt to end the previous tick, if e.g. maintenance mode was initiated while it was
// being processed
try {
this.endPreviousTick( );
} catch ( MaintenanceStatusException e1 ) {
return;
}
// Initiate next tick
long tickId;
try {
tickId = this.systemStatus.startTick( );
} catch ( TickStatusException e ) {
throw new RuntimeException( "tick initiated while previous tick still being processed" , e );
} catch ( MaintenanceStatusException e ) {
return;
}
// Execute tick
this.logger.log( LogLevel.DEBUG , "Tick " + tickId + " started" ).flush( );
this.executeTick( tickId );
}
private void endPreviousTick( )
throws MaintenanceStatusException
{
Long currentTick = this.systemStatus.checkStuckTick( );
if ( currentTick == null ) {
return;
}
this.logger.log( LogLevel.WARNING , "Tick " + currentTick + " restarted" ).flush( );
this.executeTick( currentTick.longValue( ) );
}
private void executeTick( final long tickId )
{
boolean hasMore;
do {
hasMore = this.tTemplate.execute( new TransactionCallback< Boolean >( ) {
@Override
public Boolean doInTransaction( TransactionStatus status )
{
return updatesDao.processUpdates( tickId );
}
} );
} while ( hasMore );
this.logger.log( LogLevel.TRACE , "Tick " + tickId + " completed" ).flush( );
}
}

View file

@ -1,43 +0,0 @@
package com.deepclone.lw.beans.updates;
import java.sql.Types;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
import com.deepclone.lw.interfaces.game.UpdatesDAO;
public class UpdatesDAOBean
implements UpdatesDAO
{
private SimpleJdbcCall process;
@Autowired( required = true )
public void setDataSource( DataSource dataSource )
{
this.process = new SimpleJdbcCall( dataSource );
this.process.withCatalogName( "sys" ).withFunctionName( "process_updates" );
this.process.withoutProcedureColumnMetaDataAccess( );
this.process.addDeclaredParameter( new SqlParameter( "tick_id" , Types.BIGINT ) );
this.process.addDeclaredParameter( new SqlOutParameter( "has_more" , Types.BOOLEAN ) );
}
@Override
public boolean processUpdates( long tickId )
{
Map< String , Object > m = this.process.execute( tickId );
return (Boolean) m.get( "has_more" );
}
}

View file

@ -10,13 +10,11 @@
<import resource="simple/empire-management-bean.xml" />
<import resource="simple/fleet-management-bean.xml" />
<import resource="simple/fleets-dao-bean.xml" />
<import resource="simple/game-update-bean.xml" />
<import resource="simple/map-viewer-bean.xml" />
<import resource="simple/message-beans.xml" />
<import resource="simple/planet-dao-bean.xml" />
<import resource="simple/planets-management-bean.xml" />
<import resource="simple/universe-dao-bean.xml" />
<import resource="simple/universe-generator-bean.xml" />
<import resource="simple/updates-dao-bean.xml" />
</beans>

View file

@ -4,12 +4,12 @@
<parent>
<artifactId>legacyworlds-server-beans</artifactId>
<groupId>com.deepclone.lw</groupId>
<version>5.99.1</version>
<version>5.99.2</version>
</parent>
<groupId>com.deepclone.lw</groupId>
<artifactId>legacyworlds-server-beans-system</artifactId>
<version>5.99.1</version>
<version>5.99.2</version>
<name>Legacy Worlds system management</name>
<description>This module regroups system management beans such as the constants manager.</description>
</project>

View file

@ -93,7 +93,7 @@ class ConstantsData
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "cname" , Types.VARCHAR ) );
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "cdesc" , Types.VARCHAR ) );
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "catname" , Types.VARCHAR ) );
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.REAL ) );
this.uocConstantNoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.DOUBLE ) );
this.uocConstantSingleBound = new SimpleJdbcCall( dataSource );
this.uocConstantSingleBound.withCatalogName( "sys" ).withFunctionName( "uoc_constant" );
@ -101,8 +101,8 @@ class ConstantsData
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "cname" , Types.VARCHAR ) );
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "cdesc" , Types.VARCHAR ) );
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "catname" , Types.VARCHAR ) );
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "value" , Types.REAL ) );
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "boundary" , Types.REAL ) );
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "value" , Types.DOUBLE ) );
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "boundary" , Types.DOUBLE ) );
this.uocConstantSingleBound.addDeclaredParameter( new SqlParameter( "is_min" , Types.BOOLEAN ) );
this.uocConstantTwoBounds = new SimpleJdbcCall( dataSource );
@ -111,13 +111,13 @@ class ConstantsData
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "cname" , Types.VARCHAR ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "cdesc" , Types.VARCHAR ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "catname" , Types.VARCHAR ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.REAL ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "min" , Types.REAL ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "max" , Types.REAL ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "value" , Types.DOUBLE ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "min" , Types.DOUBLE ) );
this.uocConstantTwoBounds.addDeclaredParameter( new SqlParameter( "max" , Types.DOUBLE ) );
this.fSetConstant = new StoredProc( dataSource , "sys" , "set_constant" );
this.fSetConstant.addParameter( "cname" , Types.VARCHAR );
this.fSetConstant.addParameter( "value" , Types.REAL );
this.fSetConstant.addParameter( "value" , Types.DOUBLE );
this.fSetConstant.addParameter( "admin" , Types.INTEGER );
this.tTemplate = tTemplate;
@ -149,8 +149,8 @@ class ConstantsData
c.setName( rs.getString( "name" ) );
c.setDescription( rs.getString( "description" ) );
c.setValue( rs.getDouble( "value" ) );
c.setMinValue( (Float) rs.getObject( "min" ) );
c.setMaxValue( (Float) rs.getObject( "max" ) );
c.setMinValue( (Double) rs.getObject( "min" ) );
c.setMaxValue( (Double) rs.getObject( "max" ) );
return c;
}
@ -609,7 +609,7 @@ class ConstantsData
@Override
protected void doInTransactionWithoutResult( TransactionStatus status )
{
fSetConstant.execute( name , value.floatValue( ) , admin );
fSetConstant.execute( name , value , admin );
}
} );

View file

@ -1,8 +1,9 @@
package com.deepclone.lw.beans.sys;
import java.util.Arrays;
import java.util.Collection;
import java.util.Set;
import java.util.HashSet;
import javax.sql.DataSource;
@ -92,9 +93,10 @@ public class ConstantsManagerBean
/* Documented in ConstantsManager interface */
@Override
public void registerUser( ConstantsUser user , Set< String > constants )
public void registerUser( ConstantsUser user , String... constants )
{
this.data.registerUser( user , constants );
HashSet< String > cSet = new HashSet< String >( Arrays.asList( constants ) );
this.data.registerUser( user , cSet );
}
@ -112,4 +114,5 @@ public class ConstantsManagerBean
{
return new ConstantsAdministrationImpl( this.data , admin );
}
}

View file

@ -89,7 +89,7 @@ public class ConstantsRegistrarBean
// Work and income
String[] wcNames = {
"population" , "factory" , "strikeEffect" , "wuPerPopUnit" , "destructionRecovery" , "destructionWork" ,
"rpPerPopUnit" , "cancelRecovery"
"cancelRecovery"
};
for ( int i = 0 ; i < wcNames.length ; i++ ) {
wcNames[ i ] = "game.work." + wcNames[ i ];
@ -107,10 +107,8 @@ public class ConstantsRegistrarBean
defs.add( new ConstantDefinition( wcNames[ 4 ] , cat , cDesc , 0.1 , 0.01 , 0.99 ) );
cDesc = "Proportion of a building's construction work units required to destroy it";
defs.add( new ConstantDefinition( wcNames[ 5 ] , cat , cDesc , 0.25 , 0.01 , 1.0 ) );
cDesc = "Research points per population unit.";
defs.add( new ConstantDefinition( wcNames[ 6 ] , cat , cDesc , 0.50 , 0.01 , true ) );
cDesc = "Proportion of queue investments that is recovered when flushing the queue.";
defs.add( new ConstantDefinition( wcNames[ 7 ] , cat , cDesc , 0.1 , 0.01 , 1.0 ) );
defs.add( new ConstantDefinition( wcNames[ 6 ] , cat , cDesc , 0.1 , 0.01 , 1.0 ) );
// Vacation mode
cDesc = "Initial vacation credits.";
@ -155,7 +153,7 @@ public class ConstantsRegistrarBean
// Ticker
cDesc = "Interval between ticks with the highest frequency, in milliseconds.";
defs.add( new ConstantDefinition( "ticker.interval" , "Ticker" , cDesc , 5000.0 , 1000.0 , true ) );
// Accounts
cDesc = "Minimal interval between address change requests (seconds)";
defs.add( new ConstantDefinition( "accounts.acrDelay" , "Accounts" , cDesc , 14400.0 , 1.0 , true ) );
@ -169,32 +167,43 @@ public class ConstantsRegistrarBean
defs.add( new ConstantDefinition( "accounts.banDelay" , "Accounts" , cDesc , 178000.0 , 3600.0 , true ) );
cDesc = "Delay before a ban request expires (seconds)";
defs.add( new ConstantDefinition( "accounts.banExpiration" , "Accounts" , cDesc , oneWeek , 3600.0 , true ) );
// Accounts - warnings
cDesc = "Amount of warnings that triggers an automatic ban request.";
defs.add( new ConstantDefinition( "accounts.warnings.autoBan" , "Accounts - Warnings" , cDesc , 3.0 , 1.0 , true ) );
defs.add( new ConstantDefinition( "accounts.warnings.autoBan" , "Accounts - Warnings" , cDesc , 3.0 , 1.0 ,
true ) );
cDesc = "Period after a warning is received during which additional warnings will be ignored (seconds).";
defs.add( new ConstantDefinition( "accounts.warnings.grace" , "Accounts - Warnings" , cDesc , 7200.0 , 60.0 , true ) );
defs.add( new ConstantDefinition( "accounts.warnings.grace" , "Accounts - Warnings" , cDesc , 7200.0 , 60.0 ,
true ) );
cDesc = "Time after which warnings are decreased (expressed in units as defined by a.w.expiration.units).";
defs.add( new ConstantDefinition( "accounts.warnings.expiration" , "Accounts - Warnings" , cDesc , 60.0 , 1.0 , true ) );
defs.add( new ConstantDefinition( "accounts.warnings.expiration" , "Accounts - Warnings" , cDesc , 60.0 , 1.0 ,
true ) );
cDesc = "Units used to express warning expiration time (seconds).";
defs.add( new ConstantDefinition( "accounts.warnings.expiration.units" , "Accounts - Warnings" , cDesc , 86400