Skip to content

Commit

Permalink
Ported the server to php7 and moved to different server per default
Browse files Browse the repository at this point in the history
  • Loading branch information
theZiz committed Dec 12, 2019
1 parent 5250e75 commit 896c438
Show file tree
Hide file tree
Showing 25 changed files with 192 additions and 167 deletions.
1 change: 0 additions & 1 deletion ToDo
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

3 changes: 1 addition & 2 deletions about.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
#include "client.h"
#include "lobbyList.h"

#define VERSION "1.6.5"
#define VERSION "1.6.7"

void start_about(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ));
void start_help(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ));

#endif

12 changes: 9 additions & 3 deletions build/pandora/hase/PXML.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- This is a sample PXML.xml file making use of many different things.-->
<PXML xmlns="http://openpandora.org/namespaces/PXML">
<package id="hase_prototype-hase_prototype-12345">
<version major="1" minor="6" release="5" build="0"/>
<version major="1" minor="6" release="7" build="0"/>
<author name="Ziz" website="http://ziz.openhandhelds.org"/>
<titles>
<title lang="en_US">
Expand All @@ -17,6 +17,12 @@ The used fonts are Pixel Mania by HiBan (CC-BY-SA) and DejaVu Sans (Public Domai
Changelog
=========

1.6.7:
- Ported the server to php7 and moved to different server per default

1.6.6:
- Connecting to another IRC port of one is not working

1.6.5:
- Improved camera handling, especially for small device screens

Expand Down Expand Up @@ -314,7 +320,7 @@ Changelog
- health
- more weapon points
- mine

1.4.7.2
- Added button arrow images to sparrow3d and use them now in hase in the help

Expand Down Expand Up @@ -384,7 +390,7 @@ Changelog
</package>
<application id="hase_prototype-hase_prototype-12345" appdata="hase_prototype">
<exec command="./hase.sh"/>
<version major="1" minor="6" release="5" build="0" type="release"/>
<version major="1" minor="6" release="7" build="0" type="release"/>
<!--This program's version-->
<osversion major="1" minor="0" release="0" build="0"/>
<!--The minimum OS version required-->
Expand Down
1 change: 1 addition & 0 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pMessage sendMessage(pMessage message,char* binary_name,void* binary,int count,c
spNetSendTCP(server_connection,buffer,length);
int res = spNetReceiveHTTP(server_connection,buffer,buffer_size-1);
buffer[res] = 0;
//printf("\n%s\n",buffer);
spNetCloseTCP(server_connection);
//HTTP error check + jumping to begin
if (
Expand Down
4 changes: 2 additions & 2 deletions client.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <sparrow3d.h>
#include <string.h>

#define CLIENT_VERSION 17
#define CLIENT_VERSION 18

#define TRACE_COUNT 16

Expand Down Expand Up @@ -100,7 +100,7 @@ typedef struct sHare
int hops;
int high_hops;
int health;
spSpriteCollectionPointer hase;
spSpriteCollectionPointer hase;
pHare before,next;
int wp_x,wp_y;
Sint32 cam_rotation;
Expand Down
10 changes: 8 additions & 2 deletions hase_readme.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hase
Hase
====

Hase is a game about hares in space. It is a bit like Worms or Artillery, but with gravitation.
Expand All @@ -9,6 +9,12 @@ The music is from Kevin MacLeod (CC-BY-SA)\nwww.incompetech.com
Changelog
=========

1.6.7:
- Ported the server to php7 and moved to different server per default

1.6.6:
- Connecting to another IRC port of one is not working

1.6.5:
- Improved camera handling, especially for small device screens

Expand Down Expand Up @@ -307,7 +313,7 @@ Changelog
- health
- more weapon points
- mine

1.4.7.2
- Added button arrow images to sparrow3d and use them now in hase in the help

Expand Down
2 changes: 1 addition & 1 deletion make_release_packages.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
PROGRAM="hase"
VERSION="1.6.5"
VERSION="1.6.7"
DEST=./build/*
ZIP_CALL="7z a -t7z -m0=LZMA -mmt=on -mx=9 -md=256m -mfb=512 -ms=on upload.7z"
RM_CALL="rm upload.7z"
Expand Down
25 changes: 24 additions & 1 deletion options.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ int op_game_seconds = 45;
int op_game_hares = 3;
int op_first_game = 1;
int op_sprite = 0;
int op_update_server = 0;

void sop_update_server(int v)
{
op_update_server = v;
}

int gop_update_server()
{
return op_update_server;
}

int gop_first_game()
{
Expand Down Expand Up @@ -266,6 +277,8 @@ void load_options()
sop_first_game(atoi(entry->value));
if (strcmp(entry->key,"sprite") == 0)
sop_sprite(atoi(entry->value));
if (strcmp(entry->key,"update_server") == 0)
sop_update_server(atoi(entry->value));
entry = entry->next;
}
spNetC4AProfilePointer profile;
Expand All @@ -277,6 +290,15 @@ void load_options()
sop_music_volume(gop_music_volume());
sop_sample_volume(gop_sample_volume());
spConfigFree(conf);
if (gop_update_server() == 0)
{
if ( strcmp( gop_server(), "ziz.gp2x.de/hase.php" ) == 0 )
{
sop_update_server( 1 );
sop_server("ziz.myftp.info/hase/hase.php");
save_options();
}
}
}

void save_options()
Expand All @@ -298,6 +320,7 @@ void save_options()
spConfigSetInt(conf,"game_hares",op_game_hares);
spConfigSetInt(conf,"first_game",op_first_game);
spConfigSetInt(conf,"sprite",op_sprite);
spConfigSetInt(conf,"update_server",op_update_server);
spConfigWrite(conf);
spConfigFree(conf);
}
Expand Down Expand Up @@ -485,7 +508,7 @@ int options_window(spFontPointer font, void ( *resize )( Uint16 w, Uint16 h ),in
mapping_window(font,resize,0);
}
if (window->selection == 11 && res == 1)
ret = 1;
ret = 1;
}
delete_window(window);
save_options();
Expand Down
2 changes: 2 additions & 0 deletions options.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int gop_show_map();
int gop_global_chat();
int gop_first_game();
int gop_sprite();
int gop_update_server();

void sop_zoom(int v);
void sop_circle(int v);
Expand All @@ -34,6 +35,7 @@ void sop_show_map(int v);
void sop_global_chat(int v);
void sop_first_game(int g);
void sop_sprite(int v);
void sop_update_server(int v);

Uint32* gop_game_options_ptr();
int* gop_game_hares_ptr();
Expand Down
29 changes: 15 additions & 14 deletions server/INIT_SERVER.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
<?php
include 'config.php';

$connection = mysql_connect ($mysql_host, $mysql_username, $mysql_password) or die;
mysql_select_db($mysql_dbname) or die;
$connection = mysqli_connect ($mysql_host, $mysql_username, $mysql_password, $mysql_dbname) or die;

$query = "CREATE TABLE IF NOT EXISTS `".$mysql_prefix."data_list` (".
" `game_id` int(11) NOT NULL,".
" `player_id` int(11) NOT NULL,".
" `second_of_player` int(11) NOT NULL,".
" `data` mediumblob NOT NULL".
") ENGINE=InnoDB DEFAULT CHARSET=latin1;";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;

$query = "CREATE TABLE IF NOT EXISTS `".$mysql_prefix."game_list` (".
"`game_id` int(11) NOT NULL,".
" `game_name` varchar(32) NOT NULL,".
Expand All @@ -22,7 +22,8 @@
" `level_string` varchar(512) NOT NULL,".
" `hares_per_player` int(11) NOT NULL".
") ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;

$query = "CREATE TABLE IF NOT EXISTS `".$mysql_prefix."player_list` (".
"`player_id` int(11) NOT NULL,".
" `game_id` int(11) NOT NULL,".
Expand All @@ -35,26 +36,26 @@
" `heartbeat_time` int(11) NOT NULL,".
" `nr` int(11) NOT NULL".
") ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=0;";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;

$query = "ALTER TABLE `".$mysql_prefix."data_list`".
" ADD PRIMARY KEY (`game_id`,`player_id`,`second_of_player`);";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;
$query = "ALTER TABLE `".$mysql_prefix."game_list`".
" ADD PRIMARY KEY (`game_id`), ADD UNIQUE KEY `game_id` (`game_id`);";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;
$query = "ALTER TABLE `".$mysql_prefix."player_list`".
" ADD PRIMARY KEY (`player_id`,`game_id`);";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;
$query = "ALTER TABLE `".$mysql_prefix."game_list`".
" MODIFY `game_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=0;";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;
$query = "ALTER TABLE `".$mysql_prefix."player_list`".
" MODIFY `player_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=0;";
mysql_query($query) or die;
mysqli_query($connection, $query) or die;

mysql_close($connection);
mysqli_close($connection);

echo "Success!";
echo "Delete this file now, you will not need it again!";
echo "Success!", PHP_EOL;
echo "Delete this file now, you will not need it again!", PHP_EOL;
?>
14 changes: 6 additions & 8 deletions server/change_game.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php
<?php
include 'config.php';
include 'utils.php';

$connection = mysql_connect ($mysql_host, $mysql_username, $mysql_password) or die;
mysql_select_db($mysql_dbname) or die;
$connection = mysqli_connect ($mysql_host, $mysql_username, $mysql_password, $mysql_dbname) or die;

$game_id = (int)$_POST['game_id'];
$admin_pw = (int)$_POST['admin_pw'];
Expand All @@ -12,17 +11,16 @@
$hares_per_player = (int)$_POST['hares_per_player'];

$query = "SELECT * FROM " . $mysql_prefix . "game_list WHERE game_id = '$game_id'";
$result = mysql_query($query) or die;
$result = mysqli_query($connection, $query) or die;

$row = mysql_fetch_array( $result );
$row = mysqli_fetch_array( $result );
if ($row['admin_pw'] == $admin_pw)
{
$query = "UPDATE " . $mysql_prefix . "game_list SET options='$options', seconds_per_turn='$seconds_per_turn', hares_per_player='$hares_per_player' WHERE game_id = '$game_id'";
mysql_query($query) or die;
mysqli_query( $connection, $query) or die;
}

echo "error: 0";

mysql_close($connection);
mysqli_close($connection);
?>

15 changes: 7 additions & 8 deletions server/create_game.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?php
<?php
include 'config.php';
include 'utils.php';

$connection = mysql_connect ($mysql_host, $mysql_username, $mysql_password) or die;
mysql_select_db($mysql_dbname) or die;
$connection = mysqli_connect ($mysql_host, $mysql_username, $mysql_password, $mysql_dbname) or die;

$game_name = escape_input($_POST['game_name']);
$level_string = escape_input($_POST['level_string']);
$game_name = escape_input( $connection, $_POST['game_name']);
$level_string = escape_input( $connection, $_POST['level_string']);
$options = (int)$_POST['options'];
$seconds_per_turn = (int)$_POST['seconds_per_turn'];
try {
Expand All @@ -22,10 +21,10 @@
$query = "INSERT INTO " . $mysql_prefix . "game_list (game_name, options, seconds_per_turn, admin_pw, create_date, status, level_string, hares_per_player) ".
"VALUES ( '$game_name', '$options', '$seconds_per_turn', '$admin_pw', '$create_date', '0', '$level_string', '$hares_per_player')";

mysql_query($query) or die;
$game_id = mysql_insert_id();
mysqli_query( $connection, $query) or die;
$game_id = mysqli_insert_id( $connection );
echo "game_id: $game_id", PHP_EOL;
echo "admin_pw: $admin_pw", PHP_EOL;
echo "create_date: $create_date";
mysql_close($connection);
mysqli_close($connection);
?>
15 changes: 7 additions & 8 deletions server/delete_game.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
<?php
<?php
include 'config.php';

$connection = mysql_connect ($mysql_host, $mysql_username, $mysql_password) or die;
mysql_select_db($mysql_dbname) or die;
$connection = mysqli_connect ($mysql_host, $mysql_username, $mysql_password, $mysql_dbname) or die;

$game_id = (int)$_POST['game_id'];
$admin_pw = (int)$_POST['admin_pw'];

$query = "SELECT * FROM " . $mysql_prefix . "game_list WHERE game_id = '$game_id'";
$result = mysql_query($query) or die;
$result = mysqli_query( $connection, $query) or die;

$row = mysql_fetch_array( $result );
$row = mysqli_fetch_array( $result );
if ($row['admin_pw'] == $admin_pw)
{
if ($row['status'] == 1) //closing a running game
{
$query = "UPDATE " . $mysql_prefix . "game_list SET status='-1' WHERE game_id = '$game_id'";
mysql_query($query) or die;
mysqli_query( $connection, $query) or die;
}
else
{
$query = "UPDATE " . $mysql_prefix . "game_list SET status='-2' WHERE game_id = '$game_id'";
mysql_query($query) or die;
mysqli_query( $connection, $query) or die;
}
}
echo "error: 0";
mysql_close($connection);
mysqli_close($connection);
?>
Loading

0 comments on commit 896c438

Please sign in to comment.