User and Render impl update
This commit is contained in:
parent
006d56fc8c
commit
a879fb7c4f
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Alphaland\Users {
|
||||
|
||||
use Alphaland\Users\User;
|
||||
use Alphaland\Users\Render;
|
||||
use Exception;
|
||||
use PDO;
|
||||
|
|
@ -93,7 +94,7 @@ namespace Alphaland\Users {
|
|||
$rightleg = (int)$wearingcolors->rl;
|
||||
|
||||
//currently wearing items
|
||||
$assets = wearingAssets($userid);
|
||||
$assets = User::GetWearingAssetsString($userid);
|
||||
|
||||
//add to db
|
||||
$outfit = $GLOBALS['pdo']->prepare("INSERT INTO user_outfits(userid, assets, name, h, t, la, ra, ll, rl, headshotAngleRight, headshotAngleLeft, ThumbHash, HeadshotThumbHash, whenCreated) VALUES (:uid, :assets, :name, :h, :t, :la, :ra, :ll, :rl, :har, :hal, :th, :hth, UNIX_TIMESTAMP())");
|
||||
|
|
|
|||
|
|
@ -64,84 +64,103 @@ namespace Alphaland\Users {
|
|||
return false;
|
||||
}
|
||||
|
||||
private static function SetPlayerRenderStats(int $userid)
|
||||
{
|
||||
$setrenderstat = $GLOBALS['pdo']->prepare("UPDATE users SET pendingRender = 1, pendingHeadshotRender = 1, renderCount = renderCount+1, lastRender = UNIX_TIMESTAMP(), lastHeadshotRender = UNIX_TIMESTAMP() WHERE id = :u");
|
||||
$setrenderstat->bindParam(":u", $userid, PDO::PARAM_INT);
|
||||
$setrenderstat->execute();
|
||||
if ($setrenderstat->rowCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function RenderPlayerCloseup(int $userid, bool $fork=false)
|
||||
{
|
||||
if ($fork)
|
||||
if (Render::SetPlayerRenderStats($userid))
|
||||
{
|
||||
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatarcloseup", "r"); //throwaway background process
|
||||
if ($job !== FALSE);
|
||||
if ($fork)
|
||||
{
|
||||
pclose($job);
|
||||
return true;
|
||||
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatarcloseup", "r"); //throwaway background process
|
||||
if ($job !== FALSE);
|
||||
{
|
||||
pclose($job);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$script = file_get_contents($GLOBALS['avatarcloseupthumbnailscript']);
|
||||
|
||||
$angleright = userInfo($userid)->headshotAngleRight;
|
||||
$angleleft = userInfo($userid)->headshotAngleLeft;
|
||||
|
||||
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
||||
$soap = $soap->BatchJobEx(
|
||||
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player Closeup ".$userid, $script, array(
|
||||
$userid,
|
||||
"https://www.alphaland.cc/",
|
||||
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
||||
"png",
|
||||
"840",
|
||||
"840",
|
||||
(bool)$angleright, //angleRight
|
||||
(bool)$angleleft //angleLeft
|
||||
))
|
||||
);
|
||||
|
||||
if (!is_soap_fault($soap)) {
|
||||
Render::Update($userid, $soap, true);
|
||||
return true;
|
||||
} else {
|
||||
die(print_r($soap));
|
||||
else
|
||||
{
|
||||
$script = file_get_contents($GLOBALS['avatarcloseupthumbnailscript']);
|
||||
|
||||
$angleright = userInfo($userid)->headshotAngleRight;
|
||||
$angleleft = userInfo($userid)->headshotAngleLeft;
|
||||
|
||||
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
||||
$soap = $soap->BatchJobEx(
|
||||
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player Closeup ".$userid, $script, array(
|
||||
$userid,
|
||||
"https://www.alphaland.cc/",
|
||||
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
||||
"png",
|
||||
"840",
|
||||
"840",
|
||||
(bool)$angleright, //angleRight
|
||||
(bool)$angleleft //angleLeft
|
||||
))
|
||||
);
|
||||
|
||||
if (!is_soap_fault($soap)) {
|
||||
Render::Update($userid, $soap, true);
|
||||
return true;
|
||||
} else {
|
||||
die(print_r($soap));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function RenderPlayer(int $userid, bool $fork=false)
|
||||
{
|
||||
if ($fork)
|
||||
if (Render::SetPlayerRenderStats($userid))
|
||||
{
|
||||
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatar", "r"); //throwaway background process
|
||||
if ($job !== FALSE);
|
||||
if ($fork)
|
||||
{
|
||||
pclose($job);
|
||||
return true;
|
||||
$job = popen("cd C:/Webserver/nginx/Alphaland/WebserviceTools/RenderTools && start /B php backgroundRenderJob.php ".$userid." avatar", "r"); //throwaway background process
|
||||
if ($job !== FALSE);
|
||||
{
|
||||
pclose($job);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Render::RenderPlayerCloseup($userid, true); //run in the background so it will *hopefully* finish with this
|
||||
$script = file_get_contents($GLOBALS['avatarthumbnailscript']);
|
||||
|
||||
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
||||
$soap = $soap->BatchJobEx(
|
||||
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player ".$userid, $script, array(
|
||||
$userid,
|
||||
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
||||
"https://www.alphaland.cc/",
|
||||
"png",
|
||||
"840",
|
||||
"840"
|
||||
))
|
||||
);
|
||||
|
||||
if (!is_soap_fault($soap)) {
|
||||
Render::Update($userid, $soap);
|
||||
return true;
|
||||
else
|
||||
{
|
||||
Render::RenderPlayerCloseup($userid, true); //run in the background so it will *hopefully* finish with this
|
||||
$script = file_get_contents($GLOBALS['avatarthumbnailscript']);
|
||||
|
||||
$soap = new RccServiceHelper($GLOBALS['thumbnailArbiter']);
|
||||
$soap = $soap->BatchJobEx(
|
||||
$soap->ConstructGenericJob(gen_uuid(), 25, 0, 3, "Render Player ".$userid, $script, array(
|
||||
$userid,
|
||||
"https://api.alphaland.cc/users/avatar-accoutrements?userId=".$userid,
|
||||
"https://www.alphaland.cc/",
|
||||
"png",
|
||||
"840",
|
||||
"840"
|
||||
))
|
||||
);
|
||||
|
||||
if (!is_soap_fault($soap)) {
|
||||
Render::Update($userid, $soap);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function Update(int $userid, $soapobject, $headshot=false)
|
||||
|
|
|
|||
|
|
@ -18,5 +18,53 @@ namespace Alphaland\Users {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function SetHeadshotAngleRight(int $userid)
|
||||
{
|
||||
$right = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 1, headshotAngleLeft = 0 WHERE id = :uid');
|
||||
$right->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$right->execute();
|
||||
if ($right->rowCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function SetHeadshotAngleLeft(int $userid)
|
||||
{
|
||||
$left = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 1 WHERE id = :uid');
|
||||
$left->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$left->execute();
|
||||
if ($left->rowCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function SetHeadshotAngleCenter(int $userid)
|
||||
{
|
||||
$center = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 0 WHERE id = :uid');
|
||||
$center->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$center->execute();
|
||||
if ($center->rowCount() > 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function GetWearingAssetsString(int $userid) //returns wearing asset list separated by ;
|
||||
{
|
||||
$wearingitems = $GLOBALS['pdo']->prepare('SELECT * FROM wearing_items WHERE uid = :uid ORDER BY aid ASC'); //wearing items from lowest to highest (EZ)
|
||||
$wearingitems->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$wearingitems->execute();
|
||||
|
||||
$iter = 0;
|
||||
$wearingassets = "";
|
||||
foreach($wearingitems as $item) {
|
||||
$iter += 1;
|
||||
$wearingassets .= ($iter == $wearingitems->rowCount()) ? $item['aid'] : $item['aid'] . ';';
|
||||
}
|
||||
return $wearingassets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1376,72 +1376,6 @@ function configPermission($groupid)
|
|||
|
||||
// ...
|
||||
|
||||
//render utility functions
|
||||
|
||||
function setHeadshotAngleRight($userid)
|
||||
{
|
||||
$right = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 1, headshotAngleLeft = 0 WHERE id = :uid');
|
||||
$right->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$right->execute();
|
||||
if ($right->rowCount() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setHeadshotAngleLeft($userid)
|
||||
{
|
||||
$left = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 1 WHERE id = :uid');
|
||||
$left->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$left->execute();
|
||||
if ($left->rowCount() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setHeadshotAngleCenter($userid)
|
||||
{
|
||||
$center = $GLOBALS['pdo']->prepare('UPDATE users SET headshotAngleRight = 0, headshotAngleLeft = 0 WHERE id = :uid');
|
||||
$center->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$center->execute();
|
||||
if ($center->rowCount() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function wearingAssets($userid) //returns wearing asset list separated by ;
|
||||
{
|
||||
$wearingitems = $GLOBALS['pdo']->prepare('SELECT * FROM wearing_items WHERE uid = :uid ORDER BY aid ASC'); //wearing items from lowest to highest (EZ)
|
||||
$wearingitems->bindParam(":uid", $userid, PDO::PARAM_INT);
|
||||
$wearingitems->execute();
|
||||
|
||||
$iter = 0;
|
||||
$wearingassets = "";
|
||||
foreach($wearingitems as $item)
|
||||
{
|
||||
$iter += 1;
|
||||
$wearingassets .= ($iter == $wearingitems->rowCount()) ? $item['aid'] : $item['aid'] . ';';
|
||||
}
|
||||
return $wearingassets;
|
||||
}
|
||||
|
||||
function rerenderutility()
|
||||
{
|
||||
$localplayer = $GLOBALS['user']->id;
|
||||
|
||||
$setrenderstat = $GLOBALS['pdo']->prepare("UPDATE users SET pendingRender = 1, pendingHeadshotRender = 1, renderCount = renderCount+1, lastRender = UNIX_TIMESTAMP(), lastHeadshotRender = UNIX_TIMESTAMP() WHERE id = :u");
|
||||
$setrenderstat->bindParam(":u", $localplayer, PDO::PARAM_INT);
|
||||
$setrenderstat->execute();
|
||||
UsersRender::RenderPlayer($localplayer);
|
||||
}
|
||||
|
||||
//end local user render utility functions
|
||||
|
||||
//asset functions
|
||||
|
||||
function availableAssetId() {
|
||||
|
|
@ -3181,7 +3115,7 @@ function deequipItem($assetId)
|
|||
$deequip->bindParam(":a", $assetId, PDO::PARAM_INT);
|
||||
$deequip->execute();
|
||||
|
||||
rerenderutility();
|
||||
UsersRender::RenderPlayer($localuser);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3243,7 +3177,7 @@ function equipItem($assetId)
|
|||
$equip->bindParam(":a", $assetId, PDO::PARAM_INT);
|
||||
$equip->execute();
|
||||
|
||||
rerenderutility();
|
||||
UsersRender::RenderPlayer($localuser);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ if(getBC($clr) != "-")
|
|||
$upd->bindParam(":b", $clr, PDO::PARAM_INT);
|
||||
$upd->execute();
|
||||
|
||||
rerenderutility();
|
||||
Render::RenderPlayer($localuser);
|
||||
|
||||
echo "s";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ Alphaland 2021
|
|||
//headers
|
||||
|
||||
use Alphaland\Users\Render;
|
||||
use Alphaland\Users\User;
|
||||
|
||||
header("Access-Control-Allow-Origin: https://www.alphaland.cc");
|
||||
header("access-control-allow-credentials: true");
|
||||
|
|
@ -27,22 +28,22 @@ else
|
|||
if (!Render::PendingRender($user->id))
|
||||
{
|
||||
if ($angleRight) {
|
||||
if (setHeadshotAngleRight($user->id)) {
|
||||
if (User::SetHeadshotAngleRight($user->id)) {
|
||||
$alert = true;
|
||||
}
|
||||
} else if ($angleLeft) {
|
||||
if (setHeadshotAngleLeft($user->id)) {
|
||||
if (User::SetHeadshotAngleLeft($user->id)) {
|
||||
$alert = true;
|
||||
}
|
||||
} else {
|
||||
if (setHeadshotAngleCenter($user->id)) {
|
||||
if (User::SetHeadshotAngleCenter($user->id)) {
|
||||
$alert = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($alert) {
|
||||
if (!Render::RenderCooldown($user->id)) {
|
||||
rerenderutility();
|
||||
Render::RenderPlayer($localuser);
|
||||
} else {
|
||||
$alert = "Slow down!";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue