Closed team-penguin closed 9 years ago
Is your fork available anywhere? Would love to check it out.
What Hans said. The best way to contribute larger and perhaps controversial changes is to fork the project and make the changes there. Then you don't have to involve us to merge your changes.
The following patch applies to 'NewUserForm.java'. This is the only change to the code that I have made.
--- NewUserForm.java.orig 2014-11-23 21:24:03.000000000 -0800 +++ NewUserForm.java 2014-09-15 09:48:02.000000000 -0700 @@ -21,6 +21,7 @@ import com.oddlabs.tt.util.Utils; import com.oddlabs.tt.delegate.MainMenu; import com.oddlabs.net.NetworkSelector; +import com.oddlabs.util.CryptUtils;
public final strictfp class NewUserForm extends Form { private final static int MIN_PASSWORD_LENGTH = 6; @@ -141,6 +142,7 @@ if (!login.isValid()) gui_root.addModalForm(new MessageForm(Utils.getBundleString(bundle, "invalid_login"))); else
The following SQL can be used to create the 'oddlabs' database.
CREATE DATABASE oddlabs;
USE oddlabs;
CREATE TABLE game_reports
(
game_id
int(11) NOT NULL DEFAULT '0', tick
int(11) NOT NULL DEFAULT '0', team1
int(11) NOT NULL DEFAULT '0',
team2
int(11) NOT NULL DEFAULT '0',
team3
int(11) NOT NULL DEFAULT '0',
team4
int(11) NOT NULL DEFAULT '0',
team5
int(11) NOT NULL DEFAULT '0',
team6
int(11) NOT NULL DEFAULT '0',
KEY game_id
(game_id
)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE games
(
id
int(10) unsigned NOT NULL AUTO_INCREMENT,
player1_name
varchar(20) NOT NULL DEFAULT '',
player2_name
varchar(20) NOT NULL DEFAULT '',
player3_name
varchar(20) NOT NULL DEFAULT '',
player4_name
varchar(20) NOT NULL DEFAULT '',
player5_name
varchar(20) NOT NULL DEFAULT '',
player6_name
varchar(20) NOT NULL DEFAULT '',
player1_race
enum('V','N') NOT NULL DEFAULT 'V',
player2_race
enum('V','N') NOT NULL DEFAULT 'V',
player3_race
enum('V','N') NOT NULL DEFAULT 'V',
player4_race
enum('V','N') NOT NULL DEFAULT 'V',
player5_race
enum('V','N') NOT NULL DEFAULT 'V',
player6_race
enum('V','N') NOT NULL DEFAULT 'V',
player1_team
tinyint(3) unsigned NOT NULL DEFAULT '0',
player2_team
tinyint(3) unsigned NOT NULL DEFAULT '0',
player3_team
tinyint(3) unsigned NOT NULL DEFAULT '0',
player4_team
tinyint(3) unsigned NOT NULL DEFAULT '0',
player5_team
tinyint(3) unsigned NOT NULL DEFAULT '0',
player6_team
tinyint(3) unsigned NOT NULL DEFAULT '0',
time_create
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
name
varchar(40) NOT NULL DEFAULT '',
rated
enum('N','Y') NOT NULL DEFAULT 'N',
speed
enum('1','2','3','4') NOT NULL DEFAULT '1',
size
enum('1','2','3') NOT NULL DEFAULT '1',
hills
tinyint(3) unsigned NOT NULL DEFAULT '0',
trees
tinyint(3) unsigned NOT NULL DEFAULT '0',
resources
tinyint(3) unsigned NOT NULL DEFAULT '0',
mapcode
varchar(12) NOT NULL DEFAULT '',
status
enum('created','started','completed','dropped') NOT NULL DEFAULT 'created',
winner
tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (id
)
) ENGINE=MyISAM AUTO_INCREMENT=1496876 DEFAULT CHARSET=utf8;
CREATE TABLE messages
(
id
int(10) unsigned NOT NULL AUTO_INCREMENT,
time
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
message
text NOT NULL,
KEY id
(id
)
) ENGINE=MyISAM AUTO_INCREMENT=43776 DEFAULT CHARSET=utf8;
CREATE TABLE profiles
(
id
int(11) NOT NULL AUTO_INCREMENT,
reg_id
int(11) NOT NULL DEFAULT '0',
nick
varchar(20) NOT NULL DEFAULT '',
rating
int(11) NOT NULL DEFAULT '0',
wins
int(10) NOT NULL DEFAULT '0',
losses
int(10) NOT NULL DEFAULT '0',
invalid
int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (id
),
UNIQUE KEY nick
(nick
)
) ENGINE=MyISAM AUTO_INCREMENT=93833 DEFAULT CHARSET=utf8;
CREATE TABLE registrations
(
id
int(11) NOT NULL AUTO_INCREMENT,
last_used_profile
varchar(20) NOT NULL DEFAULT '',
reg_key
varchar(20) NOT NULL,
disabled
tinyint(1) NOT NULL DEFAULT '0',
banned
tinyint(1) NOT NULL DEFAULT '0',
reg_email
varchar(60) NOT NULL DEFAULT '',
reg_time
datetime default '0000-00-00 00:00:00',
email
varchar(60) NOT NULL DEFAULT '',
timezone
tinyint(4) NOT NULL DEFAULT '0',
num_reg
int(10) unsigned NOT NULL DEFAULT '0',
name
varchar(80) NOT NULL DEFAULT '',
username
varchar(20) NOT NULL DEFAULT '',
password
varchar(40) NOT NULL DEFAULT '',
address1
varchar(40) NOT NULL DEFAULT '',
address2
varchar(40) NOT NULL DEFAULT '',
zip
varchar(40) NOT NULL DEFAULT '',
city
varchar(40) NOT NULL DEFAULT '',
state
varchar(40) NOT NULL DEFAULT '',
country
varchar(40) NOT NULL DEFAULT '',
coupon
varchar(8) NOT NULL DEFAULT '',
os
char(1) NOT NULL DEFAULT '',
affiliate
varchar(50) NOT NULL DEFAULT '',
shop
varchar(20) NOT NULL DEFAULT 'swreg',
ref
varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (id
,reg_key
),
KEY disabled
(disabled
)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
CREATE TABLE match_user
(
username
varchar(20) NOT NULL,
id
int(11) NOT NULL,
reg_key
varchar(20) NOT NULL,
password
varchar(40) NOT NULL,
email
varchar(60) NOT NULL,
last_used_profile
int(10) default NULL,
banned_until
datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (username
),
UNIQUE KEY (reg_key
),
INDEX (banned_until
),
FOREIGN KEY (id
,reg_key
) REFERENCES registrations
(id
,reg_key
)
) ENGINE=InnoDB;
CREATE TABLE online_profiles ( id int(10) unsigned NOT NULL auto_increment, nick varchar(20) NOT NULL default '', game_id int(11) NOT NULL default '2137', PRIMARY KEY (id), UNIQUE KEY nick (nick) ) ENGINE=MyISAM AUTO_INCREMENT=509 DEFAULT CHARSET=utf8;
CREATE TABLE settings
(
property
varchar(50) NOT NULL,
value
varchar(255) NOT NULL,
PRIMARY KEY (property
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE VIEW match_valid_key AS SELECT reg_key FROM registrations R WHERE NOT R.disabled;
CREATE VIEW match_valid_user AS SELECT username, password FROM match_valid_key K, match_user U WHERE U.reg_key = K.reg_key AND U.banned_until < NOW();
INSERT INTO settings
VALUES ('max_profiles', '5');
INSERT INTO settings
VALUES ('min_username_length', '2');
INSERT INTO settings
VALUES ('max_username_length', '20');
INSERT INTO settings
VALUES ('min_password_length', '6');
INSERT INTO settings
VALUES ('max_password_length', '20');
INSERT INTO settings
VALUES ('allowedchars', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789^|.,:;?+={}[]()/\&%#!<>*@$');
INSERT INTO settings
VALUES ('revision', '2137');
GRANT ALL ON oddlabs.* TO 'matchmaker'@'localhost' IDENTIFIED BY 'U46TawOp'; GRANT SELECT ON match_valid_user TO matchservlet IDENTIFIED BY 'match'; GRANT SELECT ON match_valid_key TO matchservlet; GRANT SELECT ON settings TO matchservlet; GRANT INSERT ON match_user TO matchservlet; GRANT SELECT (reg_key, username) ON match_user TO matchservlet; FLUSH PRIVILEGES;
The following SQL can be used to manually insert Users once you have discovered the PASSWORD-HASH with the aforementioned 'NewUserForm.java' patch.
use oddlabs;
delete from registrations where reg_key = 'YOUR-KEY'; delete from profiles where nick = 'joe'; delete from match_user where reg_key = 'YOUR-KEY';
insert into registrations (reg_key, name, address1, zip, city, state, country, username, email, password, reg_time) values ('YOUR-KEY', 'Joe Dirt', '123 Heyseed', '90210', 'Los Angeles', 'CA', 'USA', 'joe', 'joe@blackhole', 'PASSWORD-HASH', now());
insert into profiles (nick, rating, reg_id) values ('joe', 1000, (select id from registrations where username = 'joe'));
insert into match_user (username, id, reg_key, password, email) values ('joe', (select id from registrations where username = 'joe'), 'YOUR-KEY', 'PASSWORD-HASH', 'joe@blackhole');
All of my comments in this thread equate to what I have "changed".
If you, or anyone else, ever create a fork that makes the game easier to run, I'd be happy to link to it from the project page.
I try to follow the instructions, here the log:
(Is anybody able to post further instruction for noobs?)
trying to create database I get:
MariaDB [oddlabs]> CREATE TABLE match_user (
-> username varchar(20) NOT NULL,
-> id int(11) NOT NULL,
-> reg_key varchar(20) NOT NULL,
-> password varchar(40) NOT NULL,
-> email varchar(60) NOT NULL,
-> last_used_profile int(10) default NULL,
-> banned_until datetime NOT NULL default '0000-00-00 00:00:00',
-> PRIMARY KEY (username),
-> UNIQUE KEY (reg_key),
-> INDEX (banned_until),
-> FOREIGN KEY (id,reg_key) REFERENCES registrations (id,reg_key)
-> ) ENGINE=InnoDB;
ERROR 1005 (HY000): Can't create table oddlabs
.match_user
(errno: 150 "Foreign key constraint is incorrectly formed")
And adding:
if (!login.isValid())
gui_root.addModalForm(new MessageForm(Utils.getBundleString(bundle, "invalid_login")));
else
System.out.println("team-penguin: username = " + username + ", password = " + CryptUtils.digest(login.getPasswordDigest()) + ", " + login_details.getEmail() + ", pw_digest = " + password + ", " + login.getUsername()); doCreateUser(username, login_details, password, login); } }
to tribaltrouble/tt/classes/com/oddlabs/tt/form/NewUserForm.java I got:
/tribaltrouble/common/common.xml:37: Compile failed; see the compiler error output for details.
Regarding: ERROR 1005 (HY000): Can't create table oddlabs.match_user (errno: 150 "Foreign key constraint is incorrectly formed")
The registrations table needs to be populated with a valid id and reg_key. The 3rd post above yours has sample SQL for inserting user data into the registrations table.
The compile error is environmental, maybe you don't have javac in your path. Also, ensure that you include
import com.oddlabs.util.CryptUtils;
in the file: ./tt/classes/com/oddlabs/tt/form/NewUserForm.java
I have figured out how to run the matchmaker, router and registration services. I have added (1) line of code to expose the password hash when the game is registered. I needed to do this because the registration hangs and doesn't insert values into the database, but does progress far enough to grab the password hash. I can then manually insert users and complete the registratoin. Multiplayer works without any issues and the Single Player game works with the caveat that I have to run the client from the source directory. The game binaries seem to be built with a different password or other mechanism that prevents them from being recognized as the current version.
That is what I have, what would people like to see?