PrevDelim=i;
}
}
return MasPriem;
}
//Бросить---------------------------------------------------------------------------
//Закогнчить--------------------------------------------------------------------------
void __fastcall TMainForm::btBrosit2Click(TObject *Sender)
{
Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap();
char strSend[70];
AnsiString strCat;
if(IsServer)
{
NomHoda++;
strCat="";
}
else
{
strCat="_2";
}
if(KolKub==1)
{
int ZnachKub, XKub, YKub ;
randomize();
ZnachKub = random(6)+1;
XKub=random(126)+14;
YKub=random(126)+14;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub;
Kubiki1[0]->Top=YKub;
Kubiki1[0]->Visible=true;
MyCurOch=ZnachKub;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1, MyCurOch, MyWholeOch, ZnachKub, XKub, YKub));
}
else if (KolKub==2)
{
int ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2;
randomize();
ZnachKub1 = random(6)+1;
XKub1=random(126)+14;
YKub1=random(52)+14;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub1)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub1;
Kubiki1[0]->Top=YKub1;
Kubiki1[0]->Visible=true;
ZnachKub2 = random(6)+1;
XKub2=random(126)+14;
YKub2=random(52)+88;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub2)+strCat);
Kubiki1[1]->Picture->Bitmap=Bitmap1;
Kubiki1[1]->Left=XKub2;
Kubiki1[1]->Top=YKub2;
Kubiki1[1]->Visible=true;
MyCurOch=ZnachKub1+ZnachKub2;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1, MyCurOch, MyWholeOch, ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2));
}
else if (KolKub==3)
{
int ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2, ZnachKub3, XKub3, YKub3;
randomize();
ZnachKub1 = random(6)+1;
XKub1=random(126)+14;
YKub1=random(27)+14;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub1)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub1;
Kubiki1[0]->Top=YKub1;
Kubiki1[0]->Visible=true;
ZnachKub2 = random(6)+1;
XKub2=random(126)+14;
YKub2=random(27)+63;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub2)+strCat);
Kubiki1[1]->Picture->Bitmap=Bitmap1;
Kubiki1[1]->Left=XKub2;
Kubiki1[1]->Top=YKub2;
Kubiki1[1]->Visible=true;
ZnachKub3 = random(6)+1;
XKub3=random(126)+14;
YKub3=random(28)+112;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub3)+strCat);
Kubiki1[2]->Picture->Bitmap=Bitmap1;
Kubiki1[2]->Left=XKub3;
Kubiki1[2]->Top=YKub3;
Kubiki1[2]->Visible=true;
MyCurOch=ZnachKub1+ZnachKub2+ZnachKub3;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1, MyCurOch, MyWholeOch, ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2, ZnachKub3, XKub3, YKub3));
}
else
{
int ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2, ZnachKub3, XKub3, YKub3, ZnachKub4, XKub4, YKub4;
randomize();
ZnachKub1 = random(6)+1;
XKub1=random(52)+14;
YKub1=random(52)+14;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub1)+strCat);
Kubiki1[0]->Picture->Bitmap=Bitmap1;
Kubiki1[0]->Left=XKub1;
Kubiki1[0]->Top=YKub1;
Kubiki1[0]->Visible=true;
ZnachKub2 = random(6)+1;
XKub2=random(52)+88;
YKub2=random(52)+14;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub2)+strCat);
Kubiki1[1]->Picture->Bitmap=Bitmap1;
Kubiki1[1]->Left=XKub2;
Kubiki1[1]->Top=YKub2;
Kubiki1[1]->Visible=true;
ZnachKub3 = random(6)+1;
XKub3=random(52)+14;
YKub3=random(52)+88;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub3)+strCat);
Kubiki1[2]->Picture->Bitmap=Bitmap1;
Kubiki1[2]->Left=XKub3;
Kubiki1[2]->Top=YKub3;
Kubiki1[2]->Visible=true;
ZnachKub4 = random(6)+1;
XKub4=random(52)+88;
YKub4=random(52)+88;
Bitmap1->LoadFromResourceName((unsigned int)HInstance,"KUB"+IntToStr(ZnachKub4)+strCat);
Kubiki1[3]->Picture->Bitmap=Bitmap1;
Kubiki1[3]->Left=XKub4;
Kubiki1[3]->Top=YKub4;
Kubiki1[3]->Visible=true;
MyCurOch=ZnachKub1+ZnachKub2+ZnachKub3+ZnachKub4;
MyWholeOch=MyWholeOch+MyCurOch;
strcpy(strSend,DannieToChar(1, MyCurOch, MyWholeOch, ZnachKub1, XKub1, YKub1, ZnachKub2, XKub2, YKub2,ZnachKub3, XKub3, YKub3, ZnachKub4, XKub4, YKub4));
}
switch(choosenProt)
{
case 0:
IPXSend(strSend);
break;
case 1:
TCPIPSend(AnsiString(strSend));
break;
case 2:
NetBiosSend(strSend);
break;
case 3:
MailSlotSend(strSend);
break;
case 4:
PipeSend(strSend);
break;
}
enum TypeDannihForTabl DannieForTabl;
DannieForTabl=yabrosil;
ZapolnTabl(DannieForTabl);
lbMyWholeOch->Caption=MyWholeOch;
if (MyWholeOch>MaxOch)
{
lbMyWholeOch->Font->Color=clRed;
ViProigrali();
}
else if(IsHeFixed && MyWholeOch>HisWholeOch && MyWholeOch<=MaxOch)
{
ViViigrali();
}
else if(IsHeFixed && MyWholeOch<=HisWholeOch)
{
ChangeInterfacePerehodHoda(1);
}
else
{
ChangeInterfacePerehodHoda(0);
}
delete Bitmap1;
}
//---------------------------------------------------------------------------
void __fastcall TMainForm::btFix2Click(TObject *Sender)
{
IsYaFixed=true;
if(IsServer)
{
NomHoda++;
}
btFix->Color=clRed;
btBrosit->Color=clCream;
lbMyWholeOch->Font->Color=clRed;
switch(choosenProt)
{
case 0:
IPXSend("2;");
break;
case 1:
TCPIPSend("2;");
break;
case 2:
NetBiosSend("2;");
break;
case 3:
MailSlotSend("2;");
break;
case 4:
PipeSend("2;");
break;
}
enum TypeDannihForTabl DannieForTabl;
DannieForTabl=yafixed;
ZapolnTabl(DannieForTabl);
if(IsHeFixed && MyWholeOch==HisWholeOch)
{
Nichia();
}
else if(MyWholeOch<HisWholeOch)
{
ViProigrali();
}
else
{
ChangeInterfacePerehodHoda(0);
}
}
//---------------------------------------------------------------------------
Ipx.cpp
//---------------------------------------------------------------------------
#pragma hdrstop
#include <winsock.h>
#include <wsipx.h>
#include "IPX.h"
#include "Main.h"
#include "Podkluch.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#define IPX_SERVER_SOCKET 0x4504
#define IPX_CLIENT_SOCKET 0x4514
#define WSA_NETEVENT (WM_USER+2)
SOCKET IPXSocket;
sockaddr_ipx CallAddress;
sockaddr_ipx OurAddress;
extern bool IsServer;
extern int KolKub;
extern int MaxOch;
//-----------------------Подключение--------------------------------------------
void __fastcall TMainForm::IPXConnect(void)
{
WSADATA WSAData;
int rc, OptVal=1;
rc = WSAStartup(MAKEWORD(2,0), &WSAData);
if (rc != 0)
{
Application->MessageBox("Ошибка инициализации WSAStartup","Ошибка",MB_OK+MB_ICONHAND);
Application->Terminate();
}
IPXSocket = socket(AF_IPX, SOCK_DGRAM, NSPROTO_IPX);
if (IPXSocket == INVALID_SOCKET)
{
Application->MessageBox("Протокол IPX не установлен","Ошибка",MB_OK+MB_ICONHAND);
Application->Terminate();
}
memset(&OurAddress, 0, sizeof(OurAddress));
OurAddress.sa_family = AF_IPX;
if(IsServer)
OurAddress.sa_socket = htons((unsigned short)(IPX_SERVER_SOCKET));
else
OurAddress.sa_socket = htons((unsigned short)(IPX_CLIENT_SOCKET));
if (bind(IPXSocket, (LPSOCKADDR)&OurAddress, sizeof(sockaddr_ipx)) == SOCKET_ERROR)
{
Application->MessageBox("Адресная ошибка IPX","Ошибка",MB_OK+MB_ICONHAND);
closesocket(IPXSocket);
IPXSocket = INVALID_SOCKET;
Application->Terminate();
}
rc = setsockopt(IPXSocket, SOL_SOCKET, SO_BROADCAST, (char *)&OptVal, sizeof(OptVal));
if (rc == SOCKET_ERROR)
{
rc = WSAGetLastError();
Application->MessageBox("Ошибка setsockopt","Ошибка",MB_OK+MB_ICONHAND);
closesocket(IPXSocket);
IPXSocket = INVALID_SOCKET;
Application->Terminate();
}
if(!IsServer)
{
memset(&CallAddress, 0, sizeof(CallAddress));