Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes MST, MSX, MSL, & MTC multi-line color issues #50

Merged
merged 7 commits into from Feb 16, 2016
5 changes: 3 additions & 2 deletions PHPInSimMod.php
Expand Up @@ -58,7 +58,7 @@
*/
class PHPInSimMod
{
const VERSION = '0.5.0.1';
const VERSION = '0.5.0.2';
const ROOTPATH = ROOTPATH;

/* Run Time Arrays */
Expand Down Expand Up @@ -310,8 +310,9 @@ private function updateSelectTimeOut(&$sleep, &$uSleep)
{
$sleep = 1;
$uSleep = null;

$timeout = null;
$sleepTime = null;

foreach ($this->plugins->getPlugins() as $plugin => $object) {
$timeout = $object->executeTimers();

Expand Down
30 changes: 25 additions & 5 deletions modules/prism_packets.php
Expand Up @@ -879,8 +879,13 @@ class IS_MST extends Struct // MSg Type - send to LFS to type message or command
public function pack()
{
if (strLen($this->Msg) > 63) {
$lastColor = '^8';
foreach(explode("\n", wordwrap($this->Msg, 63, "\n", true)) as $Msg) {
$this->Msg($Msg)->Send();
$this->Msg($lastColor.$Msg)->Send();
$lastColorPosition = strrpos($Msg, '^');
if($lastColorPosition !== false) {
$lastColor = substr($Msg, $lastColorPosition, 2);
}
$this->Msg('');
}

Expand All @@ -906,8 +911,13 @@ class IS_MSX extends Struct // MSg eXtended - like MST but longer (not for comma
public function pack()
{
if (strLen($this->Msg) > 95) {
$lastColor = '^8';
foreach(explode("\n", wordwrap($this->Msg, 95, "\n", true)) as $Msg) {
$this->Msg($Msg)->Send();
$this->Msg($lastColor.$Msg)->Send();
$lastColorPosition = strrpos($Msg, '^');
if($lastColorPosition !== false) {
$lastColor = substr($Msg, $lastColorPosition, 2);
}
$this->Msg('');
}
}
Expand All @@ -931,8 +941,13 @@ class IS_MSL extends Struct // MSg Local - message to appear on local computer o
public function pack()
{
if (strLen($this->Msg) > 127){
$lastColor = '^8';
foreach(explode("\n", wordwrap($this->Msg, 127, "\n", true)) as $Msg) {
$this->Msg($Msg)->Send();
$this->Msg($lastColor.$Msg)->Send();
$lastColorPosition = strrpos($Msg, '^');
if($lastColorPosition !== false) {
$lastColor = substr($Msg, $lastColorPosition, 2);
}
$this->Msg('');
}
}
Expand Down Expand Up @@ -961,8 +976,13 @@ class IS_MTC extends Struct // Msg To Connection - hosts only - send to a connec
public function pack()
{
if (strLen($this->Text) > 127) {
$lastColor = '^8';
foreach(explode("\n", wordwrap($this->Text, 127, "\n", true)) as $Text) {
$this->Text($Text)->Send();
$this->Text($lastColor.$Text)->Send();
$lastColorPosition = strrpos($Text, '^');
if($lastColorPosition !== false) {
$lastColor = substr($Text, $lastColorPosition, 2);
}
$this->Text(''); # Prevents the last segment of the word wrap from sending twice
}
}
Expand Down Expand Up @@ -3449,4 +3469,4 @@ class IR_ERR extends Struct
$TYPEs[$Type] = substr_replace($Name, '', 2, 1);
}
$TYPEs = $SPECIAL + $TYPEs;
/* End of PRISM PACKET FOOTER */
/* End of PRISM PACKET FOOTER */
8 changes: 4 additions & 4 deletions modules/prism_plugins.php
Expand Up @@ -216,13 +216,13 @@ public function handleCmd(IS_MSO $packet)
{
if ($packet->UserType == MSO_PREFIX && ($cmdString = substr($packet->Msg, $packet->TextStart + 1)) && ($callback = $this->getCallback($this->sayCommands, $cmdString)) && $callback !== false) {
if ($this->canUserAccessCommand($packet->UCID, $callback)) {
$this->$callback['method']($cmdString, $packet->UCID, $packet);
$this->{$callback['method']}($cmdString, $packet->UCID, $packet);
} else {
console("{$this->getClientByUCID($packet->UCID)->UName} tried to access {$callback['method']}.");
}
} else if ($packet->UserType == MSO_O && ($callback = $this->getCallback($this->localCommands, $packet->Msg)) && $callback !== false) {
if ($this->canUserAccessCommand($packet->UCID, $callback)) {
$this->$callback['method']($packet->Msg, $packet->UCID, $packet);
$this->{$callback['method']}($packet->Msg, $packet->UCID, $packet);
} else {
console("{$this->getClientByUCID($packet->UCID)->UName} tried to access {$callback['method']}.");
}
Expand All @@ -234,7 +234,7 @@ public function handleInsimCmd(IS_III $packet)
{
if (($callback = $this->getCallback($this->insimCommands, $packet->Msg)) && $callback !== false) {
if ($this->canUserAccessCommand($packet->UCID, $callback)) {
$this->$callback['method']($packet->Msg, $packet->UCID, $packet);
$this->{$callback['method']}($packet->Msg, $packet->UCID, $packet);
} else {
console("{$this->getClientByUCID($packet->UCID)->UName} tried to access {$callback['method']}.");
}
Expand All @@ -245,7 +245,7 @@ public function handleInsimCmd(IS_III $packet)
public function handleConsoleCmd($string)
{
if (($callback = $this->getCallback($this->consoleCommands, $string)) && $callback !== false) {
$this->$callback['method']($string, null);
$this->{$callback['method']}($string, null);
}
}

Expand Down