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;
// char Text[TEXT_SIZE]; // up to 128 characters of text - last byte must be zero
};
/**
* Send a variable sized message to connect
*/
bool CInsim::send_mtc(void* s_mst, char *errmsg)
{
struct IS_MTC *pack_mtc = (struct IS_MTC*)s_mst;
int text_len = strlen(pack_mtc->Msg);
int text2send;
if (text_len == 0)
{
strcpy(errmsg,"strlen == 0");
return false;
}
else if (text_len > 127)
{
strcpy(errmsg,"strlen > 127");
return false;
}
text2send = text_len + 4 - text_len%4; // 4, 8 ,12, ..., 128
pack_mtc->Size = 8 + text2send;
pthread_mutex_lock (&ismutex);
if (send(sock, (const char *)pack_mtc, pack_mtc->Size, 0) < 0)
{
pthread_mutex_unlock (&ismutex);
strcpy(errmsg,"can't send mtc");
return false;
}
pthread_mutex_unlock (&ismutex);
return true;
}
<?php
x,y - curent position
polyX[] - array of X polygon points
polyY[] - array of Y polygon points
polySides - count of points
bool checkPosition(int polySides,int polyX[],int polyY[],int x,int y)
{
int i, j=polySides-1 ;
bool oddNodes=false ;
for (i=0; i<polySides; i++)
{
if (polyY[i]<y && polyY[j]>=y
|| polyY[j]<y && polyY[i]>=y)
{
if (polyX[i]+(y-polyY[i])/(polyY[j]-polyY[i])*(polyX[j]-polyX[i])<x)
{
oddNodes=!oddNodes;
}
}
j=i;
}
return oddNodes;
}
?>
int polySides = 14;
int polyX[polySides ] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int polyY[polySides ] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0};
bool Check_Pos(int polySides,int polyX[],int polyY[],float x,float y)
{
int i, j=polySides-1 ;
bool oddNodes=false ;
for (i=0; i<polySides; i++)
{
if (polyY[i]<y && polyY[j]>=y
|| polyY[j]<y && polyY[i]>=y)
{
if (polyX[i]+(y-polyY[i])/(polyY[j]-polyY[i])*(polyX[j]-polyX[i])<x)
{
oddNodes=!oddNodes;
}
}
j=i;
}
return oddNodes;
}