The online racing simulator
PHPInSimMod - PRISM 0.3.4 Discussion
You can download PHPInSimMod - PRISM 0.3.4 from that link. Please use this thread to talk about this release.

Thank you.

PHPInSimMod (PRISM) 0.3.4
  • Added Logos made by Flame CZE.
  • Fixed crash when PRISM was used with replays.
  • Removed old www-docs content.
  • Added changes Scawen made to the IS_RST packet regarding timing information.
  • Added methods to the IS_CON packet so it's easy to read the information stored within the bytes.
  • Added support for the IS_CON (Contact) packet.
  • Made sure that setting Flags for each host is properly propogated to the InSim Init packet from the Configuration file.
  • Made getClientBy(U/P)Name case insenstive.
  • Removed database module and variables until a cohesive plan emerges.
  • ISI Flags can now be set to zero.
  • Added comments to the time module.
  • ISI Flags default state no longer includes request for MCI packets.
  • Fixed parse error as reported by cargame within the prism time module.
I found DB class extending PDO which you can propably use. It need modification to support ini configs but it is good start:
<?php
class DB extends PDO{
private static $instance = NULL;
private $prefix;
public static $logA = array();

static public function gi(){
if(self::$instance == NULL ){
try{
self::$instance = new DB($dbsettings);
self::$instance -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch (PDOException $e){
die ('Blad polaczenia z baza danych: '. $e->getMessage());
}
}
return self::$instance;

}
public function __construct($configArray){
$this->prefix = $configArray['prefix'];
parent::__construct('mysql:dbname='.$configArray['name'].';host='.$configArray['server'], $configArray['user'], $configArray['pass']);
}

public function exec($query, $file, $line){
$query = str_replace('{{table}}', $this->prefix, $query);
return parent::exec($query);
}

public function query($query) {
$query = str_replace('{{table}}', $this->prefix, $query);
$start = microtime(true);
$result = parent::query($query);
$time = microtime(true) - $start;
DB::$logA[] = array('query' => $query, 'time' => round($time * 1000, 3));
return $result;
}

public static function printLog() {
$totalTime = 0;
echo '<table border=1><tr><th>Query</th><th>Time (ms)</th></tr>';
foreach(self::$logA as $entry) {
$totalTime += $entry['time'];
echo '<tr><td>' . $entry['query'] . '</td><td>' . $entry['time'] . '</td></tr>\n';
}
echo '<tr><th>' . count(self::$logA) . ' queries</th><th>' . $totalTime . '</th></tr>\n';
echo '</table>';
}

public function __destruct() {
}
}

Quote from Dygear :I really want to put some polish on the web front end for that release.

I sent you the updated Web-Frontend, kind of surprised you didn't implant it...

also, how do i turn on MCI/CON? being that the flags in ini are now observed by insim
in host config add the parameter flags with the corresponding value

e.g.
[localhost]
ip = "localhost"
port = 29999
socketType = 1
pps = 4
flags = 104

104 = 64 (ISF_CON) + 32 (ISF_MCI) + 8 (ISF_MSO_COLS)
Quote from GeForz :in host config add the parameter flags with the corresponding value

e.g.
[localhost]
ip = "localhost"
port = 29999
socketType = 1
pps = 4
flags = 104

104 = 64 (ISF_CON) + 32 (ISF_MCI) + 8 (ISF_MSO_COLS)

OK, Thanks

hmm,
Quote :IS_MTC - first byte must not be zero

Quote from T3charmy :I sent you the updated Web-Frontend, kind of surprised you didn't implant it...

Yes, I did get in, I'm going to merge it into 0.3.5 and add some things to it. I think I might have to change the interface slightly tho to ensure it works on the largest of servers.

Quote from T3charmy :IS_MTC - first byte must not be zero

Your getting this error in this build?
So not 65-66. It still have to be 0-65-66.

or

@down
You did set the "Text" variable, didn't you?

If you forget to set the Text, then the error appears.
Found the problem... in MTC it has

<?php 
    
public $Text;                        # up to 128 characters of text - last byte must be zero
?>

shouldn't it be


<?php 
    
public $Msg;                        # up to 128 characters of text - last byte must be zero
?>

All of the plugins have ->Msg not ->Text for MTC
No, as it's not a message per say. That text field could be both the caption, or the content. Anyway, the values are a direct copy of what is in the InSim.h file but translated into PHP classes. If you check the source file for InSim.h and compare it to prism_packets.php you'll notice that all of the code, even the comments for the code line up.
Quote from Dygear :No, as it's not a message per say. That text field could be both the caption, or the content. Anyway, the values are a direct copy of what is in the InSim.h file but translated into PHP classes. If you check the source file for InSim.h and compare it to prism_packets.php you'll notice that all of the code, even the comments for the code line up.

well then, seems you have a problem, as all of the plugins in prisim that use MTC have Msg not Text...

https://github.com/Dygear/PRIS ... er/plugins/admin.php#L179
https://github.com/Dygear/PRIS ... er/plugins/admin.php#L195
https://github.com/Dygear/PRIS ... r/plugins/theTime.php#L19
I don't know if what I said was 100% correct, but I do know there is a mix and match between Msg and Text. One is used for one type of message packet, and the other is used for the Button packets.

I'm starting to understand what you mean. There is a bug with my code, correct? The message your getting is not from your plugins but mine. When you have a found a bug in my code please tell me the the plugin that is causing the problem, or the module that is causing the problem and the line that it is on and I'll take a look at it when I get home.

I take it that from your 'bug report' that the problem is with the MTC class within the PRISM_PACKETS module, or it might be in any plugin that ships with PRISM that uses the MTC packet. Is that correct?
Let me solve the riddle for you:
Z28:
struct IS_MTC // Msg To Connection - hosts only - send to a connection or a player
{
byte Size; // 72
byte Type; // ISP_MTC
byte ReqI; // 0
byte Zero;

byte UCID; // connection's unique id (0 = host)
byte PLID; // player's unique id (if zero, use UCID)
byte Sp2;
byte Sp3;

[B]char Msg[64]; // last byte must be zero[/B]
};

Z30 and above:
struct IS_MTC // Msg To Connection - hosts only - send to a connection / a player / all
{
byte Size; // 8 + TEXT_SIZE (TEXT_SIZE = 4, 8, 12... 128)
byte Type; // ISP_MTC
byte ReqI; // 0
byte Sound; // sound effect (see Message Sounds below)

byte UCID; // connection's unique id (0 = host / 255 = all)
byte PLID; // player's unique id (if zero, use UCID)
byte Sp2;
byte Sp3;

[B]char Text[TEXT_SIZE]; // up to 128 characters of text - last byte must be zero[/B]
};

I recommend adding
public $Msg;

to the class and
$this->Msg = &$this->Text;

to its constructor. That way old (well, technically current) plugins will remain compatible.
Got ya Morpha! Thanks for the correction. I'll fix that once I get home. But I think I'm just going to correct my plugins as I'd like to keep the packet classes correct as per InSim.h.
Quote from Dygear :Got ya Morpha! Thanks for the correction. I'll fix that once I get home. But I think I'm just going to correct my plugins as I'd like to keep the packet classes correct as per InSim.h.

I guess i shall go ahead and update mine then?... here goes the fun :P
As it turns out there was also an intrinsic problem with the class as it still had Msg within it's self as well as part of the Pack function. So I've fixed that now. Just going to go hunting for some more bugs.

[Edit] Bug / Stupid Me: Version Number was never increased in the PHPInSim file. It still reports 0.3.3. I've updated that to 0.3.5 for now, but it's wrong in all of your versions.

FGED GREDG RDFGDR GSFDG