diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-06-22 00:52:27 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-06-22 00:52:27 -0300 |
| commit | c4dfe97e95846b43c578b3be35d0ef69f9b50e94 (patch) | |
| tree | 104189628cc30e172cd291fd56dda2382fb38ed9 | |
| parent | efeb10adcc606ad261782a260c8ef86e77ea0608 (diff) | |
| download | game-c4dfe97e95846b43c578b3be35d0ef69f9b50e94.tar.gz game-c4dfe97e95846b43c578b3be35d0ef69f9b50e94.zip | |
`sending.cc`
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | TODO.md | 1 | ||||
| -rw-r--r-- | reference/game.c | 6564 | ||||
| -rw-r--r-- | src/connections.cc | 78 | ||||
| -rw-r--r-- | src/connections.hh | 208 | ||||
| -rw-r--r-- | src/operate.hh | 3 | ||||
| -rw-r--r-- | src/sending.cc | 1751 | ||||
| -rw-r--r-- | src/stubs.hh | 55 |
8 files changed, 1969 insertions, 6697 deletions
@@ -15,7 +15,7 @@ endif HEADERS = $(SRCDIR)/common.hh $(SRCDIR)/communication.hh $(SRCDIR)/config.hh $(SRCDIR)/connections.hh $(SRCDIR)/containers.hh $(SRCDIR)/cr.hh $(SRCDIR)/crypto.hh $(SRCDIR)/enums.hh $(SRCDIR)/info.hh $(SRCDIR)/magic.hh $(SRCDIR)/map.hh $(SRCDIR)/moveuse.hh $(SRCDIR)/objects.hh $(SRCDIR)/operate.hh $(SRCDIR)/query.hh $(SRCDIR)/script.hh $(SRCDIR)/stubs.hh $(SRCDIR)/threads.hh -$(BUILDDIR)/$(OUTPUTEXE): $(BUILDDIR)/communication.obj $(BUILDDIR)/config.obj $(BUILDDIR)/connections.obj $(BUILDDIR)/cract.obj $(BUILDDIR)/crcombat.obj $(BUILDDIR)/crmain.obj $(BUILDDIR)/crplayer.obj $(BUILDDIR)/crskill.obj $(BUILDDIR)/crypto.obj $(BUILDDIR)/info.obj $(BUILDDIR)/magic.obj $(BUILDDIR)/main.obj $(BUILDDIR)/map.obj $(BUILDDIR)/moveuse.obj $(BUILDDIR)/objects.obj $(BUILDDIR)/operate.obj $(BUILDDIR)/query.obj $(BUILDDIR)/script.obj $(BUILDDIR)/shm.obj $(BUILDDIR)/strings.obj $(BUILDDIR)/threads.obj $(BUILDDIR)/time.obj $(BUILDDIR)/utils.obj +$(BUILDDIR)/$(OUTPUTEXE): $(BUILDDIR)/communication.obj $(BUILDDIR)/config.obj $(BUILDDIR)/connections.obj $(BUILDDIR)/cract.obj $(BUILDDIR)/crcombat.obj $(BUILDDIR)/crmain.obj $(BUILDDIR)/crplayer.obj $(BUILDDIR)/crskill.obj $(BUILDDIR)/crypto.obj $(BUILDDIR)/info.obj $(BUILDDIR)/magic.obj $(BUILDDIR)/main.obj $(BUILDDIR)/map.obj $(BUILDDIR)/moveuse.obj $(BUILDDIR)/objects.obj $(BUILDDIR)/operate.obj $(BUILDDIR)/query.obj $(BUILDDIR)/script.obj $(BUILDDIR)/sending.obj $(BUILDDIR)/shm.obj $(BUILDDIR)/strings.obj $(BUILDDIR)/threads.obj $(BUILDDIR)/time.obj $(BUILDDIR)/utils.obj @echo $(CC) $(CFLAGS) $(LFLAGS) -o $@ $^ $(BUILDDIR)/communication.obj: $(SRCDIR)/communication.cc $(HEADERS) @@ -90,6 +90,10 @@ $(BUILDDIR)/script.obj: $(SRCDIR)/script.cc $(HEADERS) @mkdir -p $(@D) $(CC) -c $(CFLAGS) -o $@ $< +$(BUILDDIR)/sending.obj: $(SRCDIR)/sending.cc $(HEADERS) + @mkdir -p $(@D) + $(CC) -c $(CFLAGS) -o $@ $< + $(BUILDDIR)/shm.obj: $(SRCDIR)/shm.cc $(HEADERS) @mkdir -p $(@D) $(CC) -c $(CFLAGS) -o $@ $< @@ -1,5 +1,4 @@ ## TODO NEXT -- SENDING.CC - RECEIVING.CC - QUERY.CC - HOUSES.CC <- GAME diff --git a/reference/game.c b/reference/game.c index 7958431..723efb5 100644 --- a/reference/game.c +++ b/reference/game.c @@ -26728,6570 +26728,6 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority return;
}
-
-
-bool BeginSendData(TConnection *Connection)
-
-{
- bool bVar1;
-
- bVar1 = false;
- if (Connection != (TConnection *)0x0) {
- bVar1 = false;
- if ((Connection->State - CONNECTION_LOGIN < 4) &&
- (bVar1 = false, Connection->State != CONNECTION_LOGIN)) {
- if (Connection->NextToCommit == Connection->NextToSend + 0x4000) {
- bVar1 = false;
- TConnection::GetSocket(Connection);
- print();
- }
- else {
- Connection->NextToWrite = Connection->NextToCommit;
- bVar1 = true;
- Connection->Overflow = false;
- }
- }
- }
- return bVar1;
-}
-
-
-
-void FinishSendData(TConnection *Connection)
-
-{
- if (Connection == (TConnection *)0x0) {
- Connection = (TConnection *)s_FinishSendData__Verbindung_ist_N_08108b60;
- }
- else {
- if (Connection->State - CONNECTION_LOGIN < 4) {
- if (Connection->Overflow == false) {
- Connection->NextToCommit = Connection->NextToWrite;
- if (Connection->WillingToSend == false) {
- Connection->NextSendingConnection = FirstSendingConnection;
- FirstSendingConnection = Connection;
- Connection->WillingToSend = true;
- }
- }
- else {
- print();
- }
- return;
- }
- Connection = (TConnection *)s_FinishSendData__Verbindung_ist_n_08108b20;
- }
- error((char *)Connection);
- return;
-}
-
-
-
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void SendAll(void)
-
-{
- TConnection **ppTVar1;
- pid_t __pid;
- TConnection *Connection;
- TConnection *this;
-
- this = FirstSendingConnection;
- if (FirstSendingConnection != (TConnection *)0x0) {
- do {
- if (this->WillingToSend == false) {
- error("SendAll: Verbindung ist nicht sendewillig.\n");
- }
- else {
- this->WillingToSend = false;
- if ((this->State - CONNECTION_LOGIN < 4) && (this->NextToSend != this->NextToCommit)
- ) {
- __pid = TConnection::GetPID(this);
- kill(__pid,0xc);
- }
- }
- ppTVar1 = &this->NextSendingConnection;
- this = *ppTVar1;
- } while (*ppTVar1 != (TConnection *)0x0);
- }
- FirstSendingConnection = (TConnection *)0x0;
- return;
-}
-
-
-
-void SkipFlush(TConnection *Connection)
-
-{
- int iVar1;
- int iVar2;
-
- if (Skip != -1) {
- do {
- if (Skip < 0x100) {
- iVar1 = Connection->NextToSend;
- iVar2 = Connection->NextToWrite;
- if (iVar2 < iVar1 + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = (uchar)Skip;
- iVar2 = iVar2 + 1;
- Connection->NextToWrite = iVar2;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar2 < iVar1 + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = 0xff;
- Connection->NextToWrite = iVar2 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- Skip = -1;
- }
- else {
- iVar2 = Connection->NextToWrite;
- if (iVar2 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = 0xff;
- Connection->NextToWrite = iVar2 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- iVar2 = Connection->NextToWrite;
- if (iVar2 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = 0xff;
- Connection->NextToWrite = iVar2 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- Skip = Skip + -0x100;
- }
- } while (-1 < Skip);
- }
- return;
-}
-
-
-
-void SendMapObject(TConnection *Connection,Object *Obj)
-
-{
- undefined2 uVar1;
- ushort uVar2;
- bool bVar3;
- uchar uVar4;
- TPlayer *this;
- KNOWNCREATURESTATE KVar5;
- int iVar6;
- uint uVar7;
- TPlayer *pTVar8;
- ulong uVar9;
- size_t Length;
- char *pcVar10;
- int iVar11;
- uint uVar12;
- int iVar13;
- char *s;
- uint uVar14;
- char *__s;
- char *pcVar15;
- uchar local_74;
- uchar local_4c;
- uchar local_44 [4];
- int HelpBrightness;
- int HelpColor;
- Object local_2c [7];
-
- bVar3 = Object::exists(Obj);
- if (!bVar3) {
- pcVar15 = &DAT_08108be0;
-LAB_080cc3ff:
- error(pcVar15);
- return;
- }
- Object::getObjectType(local_2c);
- if (local_2c[0].ObjectID != 99) {
- local_2c[0] = (Object)Obj->ObjectID;
- Object::getObjectType((Object *)&HelpColor);
- bVar3 = ObjectType::getFlag((ObjectType *)&HelpColor,DISGUISE);
- if (bVar3) {
- Object::getObjectType((Object *)&HelpColor);
- uVar9 = ObjectType::getAttribute((ObjectType *)&HelpColor,DISGUISETARGET);
- HelpColor._0_2_ = (undefined2)uVar9;
- }
- else {
- Object::getObjectType((Object *)&HelpColor);
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)(undefined2)HelpColor;
- uVar12 = iVar6 + 1;
- uVar7 = iVar6 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)((ushort)(undefined2)HelpColor >> 8);
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getObjectType((Object *)&HelpColor);
- bVar3 = ObjectType::getFlag((ObjectType *)&HelpColor,LIQUIDCONTAINER);
- if (bVar3) {
- uVar9 = Object::getAttribute(Obj,CONTAINERLIQUIDTYPE);
- uVar4 = GetLiquidColor(uVar9);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType((Object *)&HelpColor);
- bVar3 = ObjectType::getFlag((ObjectType *)&HelpColor,LIQUIDPOOL);
- if (bVar3) {
- uVar9 = Object::getAttribute(Obj,POOLLIQUIDTYPE);
- uVar4 = GetLiquidColor(uVar9);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType((Object *)&HelpColor);
- bVar3 = ObjectType::getFlag((ObjectType *)&HelpColor,CUMULATIVE);
- if (!bVar3) {
- return;
- }
- uVar9 = Object::getAttribute(Obj,AMOUNT);
- iVar6 = Connection->NextToWrite;
- if (Connection->NextToSend + 0x4000 <= iVar6) {
- Connection->Overflow = true;
- return;
- }
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar9;
-LAB_080cce56:
- Connection->NextToWrite = iVar6 + 1;
- return;
- }
- local_2c[0] = (Object)Obj->ObjectID;
- this = (TPlayer *)GetCreature(local_2c);
- if (this == (TPlayer *)0x0) {
- pcVar15 = "SendMapObject: Kreatur hat kein Kreatur-Objekt\n";
- goto LAB_080cc3ff;
- }
- KVar5 = TConnection::KnownCreature(Connection,(this->super_TCreature).ID,true);
- if (KVar5 == KNOWNCREATURE_UPTODATE) {
- iVar11 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = 'c';
- iVar6 = iVar6 + 1;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = '\0';
- iVar6 = iVar6 + 1;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- uVar9 = (this->super_TCreature).ID;
- if (iVar6 < iVar11 + 0x3ffd) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar9;
- uVar12 = iVar6 + 1;
- uVar7 = iVar6 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)(uVar9 >> 8);
- uVar12 = iVar6 + 2;
- uVar7 = iVar6 + 0x4001;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)(uVar9 >> 0x10);
- uVar12 = iVar6 + 3;
- uVar7 = iVar6 + 0x4002;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)(uVar9 >> 0x18);
- iVar6 = iVar6 + 4;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar11 + 0x4000 <= iVar6) {
- Connection->Overflow = true;
- return;
- }
- Connection->OutData[iVar6 % 0x4000] = (uchar)(this->super_TCreature).Direction;
- goto LAB_080cce56;
- }
- if (1 < (int)KVar5) {
- if (KVar5 != KNOWNCREATURE_OUTDATED) {
- return;
- }
- iVar11 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x4000) {
- iVar13 = iVar6 % 0x4000;
- iVar6 = iVar6 + 1;
- Connection->OutData[iVar13] = 'b';
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = '\0';
- iVar6 = iVar6 + 1;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- uVar9 = (this->super_TCreature).ID;
- if (iVar6 < iVar11 + 0x3ffd) {
- uVar12 = iVar6 + 1;
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar9;
- uVar7 = iVar6 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)(uVar9 >> 8);
- uVar12 = iVar6 + 2;
- uVar7 = iVar6 + 0x4001;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)(uVar9 >> 0x10);
- uVar12 = iVar6 + 3;
- uVar7 = iVar6 + 0x4002;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)(uVar9 >> 0x18);
- Connection->NextToWrite = iVar6 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- iVar6 = TCreature::GetHealth((TCreature *)this);
- uVar4 = (uchar)iVar6;
- iVar6 = Connection->NextToSend;
- goto LAB_080cc4e9;
- }
- if (KVar5 != KNOWNCREATURE_FREE) {
- return;
- }
- iVar11 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x4000) {
- iVar13 = iVar6 % 0x4000;
- iVar6 = iVar6 + 1;
- Connection->OutData[iVar13] = 'a';
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = '\0';
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- uVar9 = TConnection::NewKnownCreature(Connection,(this->super_TCreature).ID);
- iVar11 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x3ffd) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar9;
- uVar12 = iVar6 + 1;
- uVar7 = iVar6 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = (char)(uVar9 >> 8);
- uVar12 = iVar6 + 2;
- uVar7 = iVar6 + 0x4001;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = (char)(uVar9 >> 0x10)
- ;
- uVar12 = iVar6 + 3;
- uVar7 = iVar6 + 0x4002;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- iVar6 = iVar6 + 4;
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = (char)(uVar9 >> 0x18)
- ;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- uVar9 = (this->super_TCreature).ID;
- if (iVar6 < iVar11 + 0x3ffd) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar9;
- uVar12 = iVar6 + 1;
- uVar7 = iVar6 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = (char)(uVar9 >> 8);
- uVar12 = iVar6 + 2;
- uVar7 = iVar6 + 0x4001;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = (char)(uVar9 >> 0x10)
- ;
- uVar12 = iVar6 + 3;
- uVar7 = iVar6 + 0x4002;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = (char)(uVar9 >> 0x18)
- ;
- Connection->NextToWrite = iVar6 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- if ((this->super_TCreature).Type == MONSTER) {
- pcVar15 = (this->super_TCreature).Name;
- pcVar10 = strchr(pcVar15,0x20);
- __s = pcVar10 + 1;
- if (pcVar10 == (char *)0x0) {
- __s = pcVar15;
- }
- if (__s == (char *)0x0) goto LAB_080ccb5e;
- Length = strlen(__s);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- local_4c = (uchar)(Length & 0xffff);
- Connection->OutData[iVar6 % 0x4000] = local_4c;
- uVar12 = iVar6 + 1;
- uVar7 = iVar6 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- local_4c = (uchar)((Length & 0xffff) >> 8);
- *(uchar *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = local_4c;
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
-joined_r0x080ccbc6:
- if (0 < (int)Length) {
- SendText(Connection,__s,Length);
- }
- }
- else {
- __s = (this->super_TCreature).Name;
- if (__s != (char *)0x0) {
- Length = strlen(__s);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x3fff) {
- local_74 = (uchar)(Length & 0xffff);
- Connection->OutData[iVar6 % 0x4000] = local_74;
- uVar12 = iVar6 + 1;
- uVar7 = iVar6 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- local_74 = (uchar)((Length & 0xffff) >> 8);
- *(uchar *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) = local_74;
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- goto joined_r0x080ccbc6;
- }
-LAB_080ccb5e:
- error("SendString: String ist NULL.\n");
- }
- iVar6 = TCreature::GetHealth((TCreature *)this);
- uVar4 = (uchar)iVar6;
- iVar6 = Connection->NextToSend;
-LAB_080cc4e9:
- iVar11 = Connection->NextToWrite;
- if (iVar11 < iVar6 + 0x4000) {
- Connection->OutData[iVar11 % 0x4000] = uVar4;
- iVar11 = iVar11 + 1;
- Connection->NextToWrite = iVar11;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar11 < iVar6 + 0x4000) {
- Connection->OutData[iVar11 % 0x4000] = (uchar)(this->super_TCreature).Direction;
- iVar11 = iVar11 + 1;
- Connection->NextToWrite = iVar11;
- }
- else {
- Connection->Overflow = true;
- }
- uVar1 = (undefined2)(this->super_TCreature).Outfit.OutfitID;
- if (iVar11 < iVar6 + 0x3fff) {
- Connection->OutData[iVar11 % 0x4000] = (uchar)uVar1;
- uVar12 = iVar11 + 1;
- uVar7 = iVar11 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar1 >> 8);
- Connection->NextToWrite = iVar11 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if ((this->super_TCreature).Outfit.OutfitID == 0) {
- uVar2 = (this->super_TCreature).Outfit.field_1.ObjectType;
- iVar11 = Connection->NextToWrite;
- if (iVar11 < iVar6 + 0x3fff) {
- uVar12 = iVar11 + 1;
- Connection->OutData[iVar11 % 0x4000] = (uchar)uVar2;
- uVar7 = iVar11 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- *(char *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806) =
- (char)(uVar2 >> 8);
- Connection->NextToWrite = iVar11 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- }
- else {
- SendText(Connection,(char *)(this->super_TCreature).Outfit.field_1.Colors,4);
- }
- GetCreatureLight((this->super_TCreature).ID,(int *)local_44,&HelpBrightness);
- iVar11 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = local_44[0];
- iVar6 = iVar6 + 1;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)HelpBrightness;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- uVar7 = TCreature::GetSpeed((TCreature *)this);
- iVar6 = Connection->NextToWrite;
- iVar11 = Connection->NextToSend;
- if (iVar6 < iVar11 + 0x3fff) {
- local_74 = (uchar)(uVar7 & 0xffff);
- Connection->OutData[iVar6 % 0x4000] = local_74;
- uVar14 = iVar6 + 1;
- uVar12 = iVar6 + 0x4000;
- if (-1 < (int)uVar14) {
- uVar12 = uVar14;
- }
- local_74 = (uchar)((uVar7 & 0xffff) >> 8);
- *(uchar *)((int)Connection + (uVar14 - (uVar12 & 0xffffc000)) + 0x806) = local_74;
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if ((this->super_TCreature).Type == PLAYER) {
- pTVar8 = TConnection::GetPlayer(Connection);
- iVar6 = TPlayer::GetPlayerkillingMark(this,pTVar8);
- uVar4 = (uchar)iVar6;
- iVar11 = Connection->NextToSend;
- }
- else {
- uVar4 = '\0';
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if ((this->super_TCreature).Type == PLAYER) {
- pTVar8 = TConnection::GetPlayer(Connection);
- iVar6 = TPlayer::GetPartyMark(this,pTVar8);
- uVar4 = (uchar)iVar6;
- iVar11 = Connection->NextToSend;
- }
- else {
- uVar4 = '\0';
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar11 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- return;
-}
-
-
-
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void SendMapPoint(void)
-
-{
- int Count;
- int iVar1;
- TConnection *in_stack_00000004;
- Object local_4c [4];
- Object local_3c [4];
- ulong local_2c;
- Object Obj;
-
- GetFirstObject();
- local_3c[0].ObjectID = NONE.ObjectID;
- if (local_2c != NONE.ObjectID) {
- iVar1 = 0;
- SkipFlush(in_stack_00000004);
- if (local_2c != NONE.ObjectID) {
- do {
- iVar1 = iVar1 + 1;
- local_4c[0].ObjectID = local_2c;
- local_3c[0].ObjectID = NONE.ObjectID;
- SendMapObject(in_stack_00000004,local_4c);
- Object::getNextObject(local_3c);
- local_2c = local_3c[0].ObjectID;
- if (iVar1 == 10) break;
- } while (local_3c[0].ObjectID != NONE.ObjectID);
- }
- }
- Skip = Skip + 1;
- return;
-}
-
-
-
-void SendResult(TConnection *Connection,RESULT r)
-
-{
- int iVar1;
- bool bVar2;
- TPlayer *pTVar3;
- char *pcVar4;
-
- if (Connection == (TConnection *)0x0) {
- return;
- }
- switch(r) {
- case NOERROR:
- Connection = (TConnection *)s_SendResult__NOERROR_08109aa1;
- goto LAB_080cd2ea;
- case NOTACCESSIBLE:
- pcVar4 = "Sorry, not possible.";
- break;
- case NOTMOVABLE:
- pcVar4 = "You cannot move this object.";
- break;
- case NOTTAKABLE:
- pcVar4 = "You cannot take this object.";
- break;
- case NOROOM:
- pcVar4 = "There is not enough room.";
- break;
- case OUTOFRANGE:
- pcVar4 = "Destination is out of range.";
- break;
- case OUTOFHOME:
- Connection = (TConnection *)s_SendResult__OUTOFHOME_08109b3c;
- goto LAB_080cd2ea;
- case CANNOTTHROW:
- pcVar4 = "You cannot throw there.";
- break;
- case TOOHEAVY:
- pcVar4 = "This object is too heavy.";
- break;
- case CROSSREFERENCE:
- pcVar4 = "This is impossible.";
- break;
- case CONTAINERFULL:
- pcVar4 = "You cannot put more objects in this container.";
- break;
- case WRONGPOSITION:
- pcVar4 = "Put this object in your hand.";
- break;
- case WRONGPOSITION2:
- pcVar4 = "Put this object in both hands.";
- break;
- case WRONGCLOTHES:
- pcVar4 = "You cannot dress this object there.";
- break;
- case HANDSNOTFREE:
- pcVar4 = "Both hands have to be free.";
- break;
- case HANDBLOCKED:
- pcVar4 = "Drop the double-handed object first.";
- break;
- case ONEWEAPONONLY:
- pcVar4 = "You may only use one weapon.";
- break;
- case NOMATCH:
- Connection = (TConnection *)s_SendResult__NOMATCH_08109bf0;
- goto LAB_080cd2ea;
- case NOTCUMULABLE:
- Connection = (TConnection *)s_SendResult__NOTCUMULABLE_08109c05;
- goto LAB_080cd2ea;
- case TOOMANYPARTS:
- Connection = (TConnection *)s_SendResult__TOOMANYPARTS_08109c1f;
- goto LAB_080cd2ea;
- case EMPTYCONTAINER:
- Connection = (TConnection *)s_SendResult__EMPTYCONTAINER_08109c39;
- goto LAB_080cd2ea;
- case SPLITOBJECT:
- Connection = (TConnection *)s_SendResult__SPLITOBJECT_08109c55;
- goto LAB_080cd2ea;
- case NOKEYMATCH:
- pcVar4 = "The key does not match.";
- break;
- case UPSTAIRS:
- pcVar4 = "First go upstairs.";
- break;
- case DOWNSTAIRS:
- pcVar4 = "First go downstairs.";
- break;
- case CREATURENOTEXISTING:
- pcVar4 = "A creature with this name does not exist.";
- break;
- case PLAYERNOTEXISTING:
- pcVar4 = "A player with this name does not exist.";
- break;
- case PLAYERNOTONLINE:
- pcVar4 = "A player with this name is not online.";
- break;
- case NAMEAMBIGUOUS:
- pcVar4 = "Playername is ambiguous.";
- break;
- case NOTUSABLE:
- pcVar4 = "You cannot use this object.";
- break;
- case FEDUP:
- pcVar4 = "You are full.";
- break;
- case SPELLUNKNOWN:
- pcVar4 = "You must learn this spell first.";
- break;
- case LOWMAGICLEVEL:
- pcVar4 = "Your magic level is too low.";
- break;
- case MAGICITEM:
- pcVar4 = "A magic item is necessary to cast this spell.";
- break;
- case NOTENOUGHMANA:
- pcVar4 = "You do not have enough mana.";
- break;
- case NOSKILL:
- Connection = (TConnection *)s_SendResult__NOSKILL_08109d2b;
- goto LAB_080cd2ea;
- case TARGETLOST:
- pcVar4 = "Target lost.";
- break;
- case NOCREATURE:
- pcVar4 = "You can only use this rune on creatures.";
- break;
- case TOOLONG:
- Connection = (TConnection *)s_SendResult__TOOLONG_08109d4d;
-LAB_080cd2ea:
- error((char *)Connection);
- return;
- case ATTACKNOTALLOWED:
- pcVar4 = "You may not attack this person.";
- break;
- case NOWAY:
- pcVar4 = "There is no way.";
- break;
- case LOGINERROR:
- pcVar4 = "An error occured while logging in.";
- break;
- case PROTECTIONZONE:
- pcVar4 = "This action is not permitted in a protection zone.";
- break;
- case ENTERPROTECTIONZONE:
- pcVar4 = "Characters who attacked other players may not enter a protection zone.";
- goto LAB_080cd511;
- case EXHAUSTED:
- pcVar4 = "You are exhausted.";
- break;
- case NOTINVITED:
- pcVar4 = "You are not invited.";
- goto LAB_080cd511;
- case NOPREMIUMACCOUNT:
- pcVar4 = "You need a premium account.";
- break;
- case MOVENOTPOSSIBLE:
- pcVar4 = "Sorry, not possible.";
-LAB_080cd511:
- SendMessage(Connection,0x17,pcVar4);
- bVar2 = BeginSendData(Connection);
- if (!bVar2) {
- return;
- }
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = 0xb5;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar3 = TConnection::GetPlayer(Connection);
- if (pTVar3 == (TPlayer *)0x0) {
- return;
- }
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = (uchar)(pTVar3->super_TCreature).Direction;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- case ALREADYTRADING:
- pcVar4 = "You are already trading. Finish this trade first.";
- break;
- case PARTNERTRADING:
- pcVar4 = "This person is already trading.";
- break;
- case TOOMANYOBJECTS:
- pcVar4 = "You can only trade up to 100 objects at one time.";
- break;
- case TOOMANYSLAVES:
- pcVar4 = "You cannot control more creatures.";
- break;
- case NOTTURNABLE:
- pcVar4 = "You cannot turn this object.";
- break;
- case SECUREMODE:
- pcVar4 = "Turn secure mode off if you really want to attack unmarked players.";
- break;
- case NOTENOUGHSOULPOINTS:
- pcVar4 = "You do not have enough soulpoints.";
- break;
- case LOWLEVEL:
- pcVar4 = "Your level is too low.";
- break;
- default:
- goto switchD_080cd2dc_caseD_ffffffff;
- }
- SendMessage(Connection,0x17,pcVar4);
-switchD_080cd2dc_caseD_ffffffff:
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Color
-
-void SendRefresh(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- uchar local_18 [4];
- int Brightness;
- int Color;
-
- SendFullScreen(Connection);
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0x82;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- GetAmbiente((int *)local_18,&Brightness);
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = local_18[0];
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)Brightness;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- }
- SendPlayerData(Connection);
- SendPlayerSkills(Connection);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: id_local
-
-void __regparm2 SendInitGame(TConnection *Connection,ulong id)
-
-{
- int iVar1;
- undefined2 uVar2;
- bool bVar3;
- int iVar4;
- uint uVar5;
- uint uVar6;
- TConnection *in_stack_00000004;
- ulong in_stack_00000008;
- uchar local_14;
- ulong id_local;
-
- bVar3 = BeginSendData(in_stack_00000004);
- if (bVar3) {
- iVar1 = in_stack_00000004->NextToSend;
- iVar4 = in_stack_00000004->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- in_stack_00000004->OutData[iVar4 % 0x4000] = '\n';
- iVar4 = iVar4 + 1;
- in_stack_00000004->NextToWrite = iVar4;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3ffd) {
- uVar6 = iVar4 + 1;
- local_14 = (uchar)in_stack_00000008;
- in_stack_00000004->OutData[iVar4 % 0x4000] = local_14;
- uVar5 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar5 = uVar6;
- }
- *(char *)((int)in_stack_00000004 + (uVar6 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)(in_stack_00000008 >> 8);
- uVar6 = iVar4 + 2;
- uVar5 = iVar4 + 0x4001;
- if (-1 < (int)uVar6) {
- uVar5 = uVar6;
- }
- *(char *)((int)in_stack_00000004 + (uVar6 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)(in_stack_00000008 >> 0x10);
- uVar6 = iVar4 + 3;
- uVar5 = iVar4 + 0x4002;
- if (-1 < (int)uVar6) {
- uVar5 = uVar6;
- }
- *(char *)((int)in_stack_00000004 + (uVar6 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)(in_stack_00000008 >> 0x18);
- iVar4 = iVar4 + 4;
- in_stack_00000004->NextToWrite = iVar4;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- uVar2 = (undefined2)Beat;
- if (iVar4 < iVar1 + 0x3fff) {
- uVar6 = iVar4 + 1;
- in_stack_00000004->OutData[iVar4 % 0x4000] = (uchar)(undefined2)Beat;
- uVar5 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar5 = uVar6;
- }
- *(char *)((int)in_stack_00000004 + (uVar6 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar2 >> 8);
- in_stack_00000004->NextToWrite = iVar4 + 2;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- bVar3 = CheckRight(in_stack_00000008,SEND_BUGREPORTS);
- iVar4 = in_stack_00000004->NextToWrite;
- if (iVar4 < in_stack_00000004->NextToSend + 0x4000) {
- in_stack_00000004->OutData[iVar4 % 0x4000] = bVar3;
- in_stack_00000004->NextToWrite = iVar4 + 1;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- FinishSendData(in_stack_00000004);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Connection_local
-
-void __regparm2 SendRights(TConnection *Connection)
-
-{
- bool bVar1;
- bool bVar2;
- TPlayer *pTVar3;
- int Action;
- int iVar4;
- int Reason;
- int Actions;
- uint uVar5;
- TConnection *in_stack_00000004;
- RIGHT local_20;
- int Right;
- bool SendIt;
- TPlayer *pl;
- TConnection *Connection_local;
-
- bVar1 = BeginSendData(in_stack_00000004);
- if (bVar1) {
- iVar4 = in_stack_00000004->NextToWrite;
- if (iVar4 < in_stack_00000004->NextToSend + 0x4000) {
- in_stack_00000004->OutData[iVar4 % 0x4000] = '\v';
- in_stack_00000004->NextToWrite = iVar4 + 1;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- pTVar3 = TConnection::GetPlayer(in_stack_00000004);
- bVar1 = false;
- local_20 = NAME_INSULTING;
- do {
- bVar2 = CheckRight((pTVar3->super_TCreature).ID,local_20);
- uVar5 = 0;
- if (bVar2) {
- iVar4 = 0;
- uVar5 = 0;
- do {
- bVar2 = CheckBanishmentRight
- ((pTVar3->super_TCreature).ID,local_20 - NAME_INSULTING,iVar4)
- ;
- if (bVar2) {
- uVar5 = uVar5 | 1 << ((byte)iVar4 & 0x1f);
- }
- iVar4 = iVar4 + 1;
- } while (iVar4 < 7);
- if (uVar5 != 0) {
- bVar2 = CheckRight((pTVar3->super_TCreature).ID,IP_BANISHMENT);
- if (bVar2) {
- uVar5 = uVar5 | 0x80;
- }
- }
- }
- iVar4 = in_stack_00000004->NextToWrite;
- if (iVar4 < in_stack_00000004->NextToSend + 0x4000) {
- in_stack_00000004->OutData[iVar4 % 0x4000] = (uchar)uVar5;
- in_stack_00000004->NextToWrite = iVar4 + 1;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- if (uVar5 != 0) {
- bVar1 = true;
- }
- local_20 = local_20 + NOTATION;
- } while ((int)local_20 < 0x32);
- if (bVar1) {
- FinishSendData(in_stack_00000004);
- return;
- }
- }
- return;
-}
-
-
-
-void SendPing(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = '\x1e';
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: posz
-
-void SendFullScreen(TConnection *Connection)
-
-{
- bool bVar1;
- int iVar2;
- uint uVar3;
- uint uVar4;
- int y;
- int iVar5;
- int iVar6;
- int z_1;
- int z;
- int iVar7;
- int local_30;
- int local_2c;
- int x_1;
- int x;
- int sy;
- int sx;
- int posx;
- int posy;
- int posz;
-
- bVar1 = BeginSendData(Connection);
- if (bVar1) {
- iVar7 = Connection->NextToWrite;
- if (iVar7 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar7 % 0x4000] = 'd';
- Connection->NextToWrite = iVar7 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- TConnection::GetPosition(Connection,&sx,&posx,&posy);
- iVar2 = Connection->NextToSend;
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar2 + 0x3fff) {
- Connection->OutData[iVar7 % 0x4000] = (uchar)(undefined2)sx;
- uVar4 = iVar7 + 1;
- uVar3 = iVar7 + 0x4000;
- if (-1 < (int)uVar4) {
- uVar3 = uVar4;
- }
- *(char *)((int)Connection + (uVar4 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((ushort)(undefined2)sx >> 8);
- iVar7 = iVar7 + 2;
- Connection->NextToWrite = iVar7;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar7 < iVar2 + 0x3fff) {
- uVar4 = iVar7 + 1;
- Connection->OutData[iVar7 % 0x4000] = (uchar)(undefined2)posx;
- uVar3 = iVar7 + 0x4000;
- if (-1 < (int)uVar4) {
- uVar3 = uVar4;
- }
- *(char *)((int)Connection + (uVar4 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((ushort)(undefined2)posx >> 8);
- iVar7 = iVar7 + 2;
- Connection->NextToWrite = iVar7;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar7 < iVar2 + 0x4000) {
- Connection->OutData[iVar7 % 0x4000] = (uchar)posy;
- Connection->NextToWrite = iVar7 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- Skip = -1;
- if (posy < 8) {
- iVar7 = 7;
- local_30 = Connection->TerminalWidth;
- do {
- x_1 = 0;
- if (0 < local_30) {
- iVar2 = Connection->TerminalHeight;
- do {
- iVar5 = 0;
- if (0 < iVar2) {
- do {
- iVar5 = iVar5 + 1;
- SendMapPoint();
- iVar2 = Connection->TerminalHeight;
- } while (iVar5 < iVar2);
- local_30 = Connection->TerminalWidth;
- }
- x_1 = x_1 + 1;
- } while (x_1 < local_30);
- }
- iVar7 = iVar7 + -1;
- } while (-1 < iVar7);
- }
- else {
- iVar7 = posy + -2;
- if ((iVar7 <= posy + 2) && (iVar7 < 0x10)) {
- local_30 = Connection->TerminalWidth;
- iVar2 = posy;
- do {
- local_2c = 0;
- if (0 < local_30) {
- iVar5 = Connection->TerminalHeight;
- do {
- iVar6 = 0;
- if (0 < iVar5) {
- do {
- iVar6 = iVar6 + 1;
- SendMapPoint();
- iVar5 = Connection->TerminalHeight;
- } while (iVar6 < iVar5);
- local_30 = Connection->TerminalWidth;
- iVar2 = posy;
- }
- local_2c = local_2c + 1;
- } while (local_2c < local_30);
- }
- iVar7 = iVar7 + 1;
- } while ((iVar7 <= iVar2 + 2) && (iVar7 < 0x10));
- }
- }
- SkipFlush(Connection);
- FinishSendData(Connection);
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: posz
-
-void SendRow(TConnection *Connection,int Direction)
-
-{
- bool bVar1;
- int iVar2;
- int iVar3;
- int z;
- int iVar4;
- int local_2c;
- int end;
- int dz;
- int sy;
- int sx;
- int posx;
- int posy;
- int posz;
-
- bVar1 = BeginSendData(Connection);
- if (!bVar1) {
- return;
- }
- if (Direction == 1) {
- iVar4 = Connection->NextToWrite;
- if (Connection->NextToSend + 0x4000 <= iVar4) goto LAB_080cdfdc;
- Connection->OutData[iVar4 % 0x4000] = 'f';
- }
- else if (Direction < 2) {
- if (Direction != 0) {
-LAB_080cdfab:
- error(&DAT_08109140,Direction);
- return;
- }
- iVar4 = Connection->NextToWrite;
- if (Connection->NextToSend + 0x4000 <= iVar4) goto LAB_080cdfdc;
- Connection->OutData[iVar4 % 0x4000] = 'e';
- }
- else if (Direction == 2) {
- iVar4 = Connection->NextToWrite;
- if (Connection->NextToSend + 0x4000 <= iVar4) {
-LAB_080cdfdc:
- Connection->Overflow = true;
- goto LAB_080cdfe3;
- }
- Connection->OutData[iVar4 % 0x4000] = 'g';
- }
- else {
- if (Direction != 3) goto LAB_080cdfab;
- iVar4 = Connection->NextToWrite;
- if (Connection->NextToSend + 0x4000 <= iVar4) goto LAB_080cdfdc;
- Connection->OutData[iVar4 % 0x4000] = 'h';
- }
- Connection->NextToWrite = iVar4 + 1;
-LAB_080cdfe3:
- TConnection::GetPosition(Connection,&sx,&posx,&posy);
- Skip = -1;
- if (posy < 8) {
- end = -1;
- iVar4 = 7;
- local_2c = -1;
- }
- else {
- end = 1;
- iVar4 = posy + -2;
- local_2c = 0x10;
- if (posy + 3 < 0x11) {
- local_2c = posy + 3;
- }
- }
- if (Direction == 1) {
- if (iVar4 != local_2c) {
- iVar2 = Connection->TerminalHeight;
- do {
- iVar3 = 0;
- if (0 < iVar2) {
- do {
- iVar3 = iVar3 + 1;
- SendMapPoint();
- iVar2 = Connection->TerminalHeight;
- } while (iVar3 < iVar2);
- }
- iVar4 = iVar4 + end;
- } while (iVar4 != local_2c);
- }
- }
- else if (Direction < 2) {
- if ((Direction == 0) && (iVar4 != local_2c)) {
- iVar2 = Connection->TerminalWidth;
- do {
- iVar3 = 0;
- if (0 < iVar2) {
- do {
- iVar3 = iVar3 + 1;
- SendMapPoint();
- iVar2 = Connection->TerminalWidth;
- } while (iVar3 < iVar2);
- }
- iVar4 = iVar4 + end;
- } while (iVar4 != local_2c);
- }
- }
- else if (Direction == 2) {
- if (iVar4 != local_2c) {
- iVar2 = Connection->TerminalWidth;
- do {
- iVar3 = 0;
- if (0 < iVar2) {
- do {
- iVar3 = iVar3 + 1;
- SendMapPoint();
- iVar2 = Connection->TerminalWidth;
- } while (iVar3 < iVar2);
- }
- iVar4 = iVar4 + end;
- } while (iVar4 != local_2c);
- }
- }
- else if ((Direction == 3) && (iVar4 != local_2c)) {
- iVar2 = Connection->TerminalHeight;
- do {
- iVar3 = 0;
- if (0 < iVar2) {
- do {
- iVar3 = iVar3 + 1;
- SendMapPoint();
- iVar2 = Connection->TerminalHeight;
- } while (iVar3 < iVar2);
- }
- iVar4 = iVar4 + end;
- } while (iVar4 != local_2c);
- }
- SkipFlush(Connection);
- FinishSendData(Connection);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: posz
-
-void SendFloors(TConnection *Connection,bool Up)
-
-{
- bool bVar1;
- int iVar2;
- int iVar3;
- int iVar4;
- int z;
- int iVar5;
- int local_30;
- int x;
- int sy;
- int sx;
- int dz;
- int end;
- int posx;
- int posy;
- int posz;
-
- bVar1 = BeginSendData(Connection);
- if (!bVar1) {
- return;
- }
- iVar5 = Connection->NextToWrite;
- if (iVar5 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar5 % 0x4000] = !Up + 0xbe;
- Connection->NextToWrite = iVar5 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- TConnection::GetPosition(Connection,&end,&posx,&posy);
- if (Up) {
- if (7 < posy) {
- sx = -1;
- iVar5 = posy + -2;
- dz = posy + -3;
- goto LAB_080ce3a4;
- }
- if (posy != 7) goto LAB_080ce47c;
- sx = -1;
- iVar5 = 5;
- }
- else {
- if (8 < posy) {
- sx = 1;
- iVar5 = posy + 2;
- dz = posy + 3;
- if (0x10 < iVar5) {
- iVar5 = 0x10;
- }
- if (0x10 < dz) {
- dz = 0x10;
- }
- goto LAB_080ce3a4;
- }
- if (posy == 8) {
- sx = 1;
- iVar5 = 8;
- dz = 0xb;
- goto LAB_080ce3a4;
- }
-LAB_080ce47c:
- sx = 0;
- iVar5 = -1;
- }
- dz = -1;
-LAB_080ce3a4:
- Skip = -1;
- if (iVar5 != dz) {
- iVar3 = Connection->TerminalWidth;
- do {
- local_30 = 0;
- if (0 < iVar3) {
- iVar2 = Connection->TerminalHeight;
- do {
- iVar4 = 0;
- if (0 < iVar2) {
- do {
- iVar4 = iVar4 + 1;
- SendMapPoint();
- iVar2 = Connection->TerminalHeight;
- } while (iVar4 < iVar2);
- iVar3 = Connection->TerminalWidth;
- }
- local_30 = local_30 + 1;
- } while (local_30 < iVar3);
- }
- iVar5 = iVar5 + sx;
- } while (iVar5 != dz);
- }
- SkipFlush(Connection);
- FinishSendData(Connection);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: x_local
-
-void __regparm2 SendFieldData(TConnection *Connection,int x,int y,int z)
-
-{
- int iVar1;
- bool bVar2;
- uint uVar3;
- int iVar4;
- uint uVar5;
- int iVar6;
- undefined4 in_stack_0000000c;
- undefined1 in_stack_00000010;
- int z_local;
- int y_local;
- int x_local;
-
- bVar2 = BeginSendData((TConnection *)y);
- if (bVar2) {
- iVar1 = *(int *)(y + 0x4808);
- iVar4 = *(int *)(y + 0x4810);
- if (iVar4 < iVar1 + 0x4000) {
- iVar6 = iVar4 % 0x4000;
- iVar4 = iVar4 + 1;
- *(undefined1 *)(y + 0x806 + iVar6) = 0x69;
- *(int *)(y + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(y + 0x806 + iVar4 % 0x4000) = (char)z;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 2;
- *(char *)(y + 0x806 + (uVar5 - (uVar3 & 0xffffc000))) = (char)((uint)z >> 8);
- *(int *)(y + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(y + 0x806 + iVar4 % 0x4000) = (char)in_stack_0000000c;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 2;
- *(char *)(y + 0x806 + (uVar5 - (uVar3 & 0xffffc000))) =
- (char)((uint)in_stack_0000000c >> 8);
- *(int *)(y + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x4000) {
- *(undefined1 *)(y + 0x806 + iVar4 % 0x4000) = in_stack_00000010;
- *(int *)(y + 0x4810) = iVar4 + 1;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- Skip = -1;
- SendMapPoint();
- SkipFlush((TConnection *)y);
- FinishSendData((TConnection *)y);
- return;
- }
- return;
-}
-
-
-
-void SendCloseContainer(TConnection *Connection,int ContNr)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 'o';
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)ContNr;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-void SendContainer(TConnection *Connection,int ContNr)
-
-{
- int iVar1;
- bool bVar2;
- uchar uVar3;
- TPlayer *pl;
- TPlayer *Window;
- ulong uVar4;
- char *__s;
- size_t Length;
- uint uVar5;
- int iVar6;
- uint uVar7;
- undefined2 uVar8;
- int *piVar9;
- undefined4 uVar10;
- int local_6c;
- int Count;
- int local_60;
- Object local_5c [4];
- Object local_4c [4];
- Object local_3c [4];
- Object local_2c;
- Object Obj;
-
- bVar2 = BeginSendData(Connection);
- if (!bVar2) {
- return;
- }
- iVar1 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar1 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = 'n';
- iVar6 = iVar6 + 1;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar1 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)ContNr;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- Window = TConnection::GetPlayer(Connection);
- if (Window == (TPlayer *)0x0) {
- error(&DAT_081091c0);
- return;
- }
- iVar6 = ContNr;
- TPlayer::GetOpenContainer((TPlayer *)&local_2c,(int)Window);
- bVar2 = Object::exists(&local_2c);
- if (!bVar2) {
- error("SendContainer: Container %d existiert nicht.\n",ContNr,iVar6);
- return;
- }
- local_3c[0].ObjectID = local_2c.ObjectID;
- Object::getObjectType(local_4c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_4c,DISGUISE);
- if (bVar2) {
- Object::getObjectType(local_4c);
- uVar4 = ObjectType::getAttribute((ObjectType *)local_4c,DISGUISETARGET);
- uVar8 = (undefined2)uVar4;
- }
- else {
- Object::getObjectType(local_4c);
- uVar8 = (undefined2)local_4c[0].ObjectID;
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar8;
- uVar7 = iVar6 + 1;
- uVar5 = iVar6 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar8 >> 8);
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getObjectType(local_4c);
- uVar10 = 0xffffffff;
- __s = ObjectType::getName((ObjectType *)local_4c);
- if (__s == (char *)0x0) {
- error("SendString: String ist NULL.\n",uVar10);
- }
- else {
- Length = strlen(__s);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- Count._0_1_ = (uchar)(Length & 0xffff);
- Connection->OutData[iVar6 % 0x4000] = (uchar)Count;
- uVar7 = iVar6 + 1;
- uVar5 = iVar6 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- Count._0_1_ = (uchar)((Length & 0xffff) >> 8);
- *(uchar *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) = (uchar)Count;
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,__s,Length);
- }
- }
- Object::getObjectType(local_4c);
- uVar4 = ObjectType::getAttribute((ObjectType *)local_4c,CAPACITY);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getContainer(local_4c);
- Object::getObjectType(local_3c);
- if ((_func_int_varargs **)local_3c[0].ObjectID != (_func_int_varargs **)0x0) {
- Object::getContainer(local_3c);
- Object::getObjectType(local_5c);
- bVar2 = false;
- if ((0 < (int)local_5c[0].ObjectID) && ((int)local_5c[0].ObjectID < 0xb)) {
- bVar2 = true;
- }
- uVar3 = '\x01';
- if (!bVar2) goto LAB_080ce9df;
- }
- uVar3 = '\0';
-LAB_080ce9df:
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- local_5c[0].ObjectID = local_2c.ObjectID;
- local_60 = CountObjectsInContainer(local_5c);
- iVar6 = Connection->NextToWrite;
- piVar9 = &OBJECTS_PER_CONTAINER;
- if (local_60 < 0x25) {
- piVar9 = &local_60;
- }
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)*piVar9;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- local_6c = 0;
- local_3c[0].ObjectID = local_2c.ObjectID;
- GetFirstContainerObject(local_4c);
- local_2c.ObjectID = local_4c[0].ObjectID;
- while( true ) {
- bVar2 = false;
- local_5c[0].ObjectID = NONE.ObjectID;
- local_4c[0].ObjectID = NONE.ObjectID;
- if ((local_2c.ObjectID != NONE.ObjectID) && (local_6c < 0x24)) {
- bVar2 = true;
- }
- if (!bVar2) break;
- local_5c[0].ObjectID = local_2c.ObjectID;
- Object::getObjectType(local_4c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_4c,DISGUISE);
- if (bVar2) {
- Object::getObjectType(local_4c);
- uVar4 = ObjectType::getAttribute((ObjectType *)local_4c,DISGUISETARGET);
- uVar8 = (undefined2)uVar4;
- }
- else {
- Object::getObjectType(local_4c);
- uVar8 = (undefined2)local_4c[0].ObjectID;
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar8;
- uVar7 = iVar6 + 1;
- uVar5 = iVar6 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar8 >> 8);
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getObjectType(local_5c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_5c,LIQUIDCONTAINER);
- if (bVar2) {
- uVar4 = Object::getAttribute(&local_2c,CONTAINERLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_5c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_5c,LIQUIDPOOL);
- if (bVar2) {
- uVar4 = Object::getAttribute(&local_2c,POOLLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_5c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_5c,CUMULATIVE);
- if (bVar2) {
- uVar4 = Object::getAttribute(&local_2c,AMOUNT);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getNextObject(local_4c);
- local_2c.ObjectID = local_4c[0].ObjectID;
- local_6c = local_6c + 1;
- }
- FinishSendData(Connection);
- return;
-}
-
-
-
-void SendCreateInContainer(TConnection *Connection,int ContNr,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- uchar uVar3;
- ulong uVar4;
- uint uVar5;
- int iVar6;
- uint uVar7;
- Object local_3c [4];
- ulong local_2c;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar1 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = 'p';
- iVar6 = iVar6 + 1;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar1 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)ContNr;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- local_2c = Obj->ObjectID;
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,DISGUISE);
- if (bVar2) {
- Object::getObjectType(local_3c);
- uVar4 = ObjectType::getAttribute((ObjectType *)local_3c,DISGUISETARGET);
- local_3c[0].ObjectID._0_2_ = (undefined2)uVar4;
- }
- else {
- Object::getObjectType(local_3c);
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)(undefined2)local_3c[0].ObjectID;
- uVar7 = iVar6 + 1;
- uVar5 = iVar6 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)(undefined2)local_3c[0].ObjectID >> 8);
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,LIQUIDCONTAINER);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,CONTAINERLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,LIQUIDPOOL);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,POOLLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,CUMULATIVE);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,AMOUNT);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- FinishSendData(Connection);
- }
- else {
- error(&DAT_08109200);
- }
- }
- return;
-}
-
-
-
-void SendChangeInContainer(TConnection *Connection,int ContNr,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- uchar uVar3;
- int iVar4;
- ulong uVar5;
- uint uVar6;
- int iVar7;
- uint uVar8;
- uchar local_40;
- int RNum;
- Object local_2c [7];
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c[0] = (Object)Obj->ObjectID;
- iVar4 = GetObjectRNum(local_2c);
- if (iVar4 < 0x24) {
- iVar1 = Connection->NextToSend;
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar1 + 0x4000) {
- Connection->OutData[iVar7 % 0x4000] = 'q';
- iVar7 = iVar7 + 1;
- Connection->NextToWrite = iVar7;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar7 < iVar1 + 0x4000) {
- Connection->OutData[iVar7 % 0x4000] = (uchar)ContNr;
- iVar7 = iVar7 + 1;
- Connection->NextToWrite = iVar7;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar7 < iVar1 + 0x4000) {
- local_40 = (uchar)iVar4;
- Connection->NextToWrite = iVar7 + 1;
- Connection->OutData[iVar7 % 0x4000] = local_40;
- }
- else {
- Connection->Overflow = true;
- }
- local_2c[0] = (Object)Obj->ObjectID;
- Object::getObjectType((Object *)&RNum);
- bVar2 = ObjectType::getFlag((ObjectType *)&RNum,DISGUISE);
- if (bVar2) {
- Object::getObjectType((Object *)&RNum);
- uVar5 = ObjectType::getAttribute((ObjectType *)&RNum,DISGUISETARGET);
- RNum._0_2_ = (undefined2)uVar5;
- }
- else {
- Object::getObjectType((Object *)&RNum);
- }
- iVar4 = Connection->NextToWrite;
- if (iVar4 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(undefined2)RNum;
- uVar8 = iVar4 + 1;
- uVar6 = iVar4 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar6 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar6 & 0xffffc000)) + 0x806) =
- (char)((ushort)(undefined2)RNum >> 8);
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getObjectType((Object *)&RNum);
- bVar2 = ObjectType::getFlag((ObjectType *)&RNum,LIQUIDCONTAINER);
- if (bVar2) {
- uVar5 = Object::getAttribute(Obj,CONTAINERLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar5);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType((Object *)&RNum);
- bVar2 = ObjectType::getFlag((ObjectType *)&RNum,LIQUIDPOOL);
- if (bVar2) {
- uVar5 = Object::getAttribute(Obj,POOLLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar5);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType((Object *)&RNum);
- bVar2 = ObjectType::getFlag((ObjectType *)&RNum,CUMULATIVE);
- if (bVar2) {
- uVar5 = Object::getAttribute(Obj,AMOUNT);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)uVar5;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- FinishSendData(Connection);
- }
- }
- else {
- error(&DAT_08109240);
- }
- }
- return;
-}
-
-
-
-void SendDeleteInContainer(TConnection *Connection,int ContNr,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- int iVar4;
- int RNum;
- Object local_2c [7];
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c[0] = (Object)Obj->ObjectID;
- iVar3 = GetObjectRNum(local_2c);
- if (iVar3 < 0x24) {
- iVar1 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 'r';
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)ContNr;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)iVar3;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- }
- }
- else {
- error(&DAT_08109280);
- }
- }
- return;
-}
-
-
-
-void SendBodyInventory(TConnection *Connection,ulong CreatureID)
-
-{
- int Position;
- int Position_00;
- Object local_4c [4];
- ulong local_3c;
- ulong local_2c;
- Object Obj;
-
- Position_00 = 1;
- do {
- GetBodyObject((ulong)&local_2c,CreatureID);
- local_3c = NONE.ObjectID;
- local_4c[0].ObjectID = NONE.ObjectID;
- if (local_2c != NONE.ObjectID) {
- local_4c[0].ObjectID = local_2c;
- SendSetInventory(Connection,Position_00,local_4c);
- }
- Position_00 = Position_00 + 1;
- } while (Position_00 < 0xb);
- return;
-}
-
-
-
-void SendSetInventory(TConnection *Connection,int Position,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- uchar uVar3;
- ulong uVar4;
- uint uVar5;
- int iVar6;
- uint uVar7;
- Object local_3c [4];
- ulong local_2c;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar1 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = 'x';
- iVar6 = iVar6 + 1;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar1 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)Position;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c = Obj->ObjectID;
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,DISGUISE);
- if (bVar2) {
- Object::getObjectType(local_3c);
- uVar4 = ObjectType::getAttribute((ObjectType *)local_3c,DISGUISETARGET);
- local_3c[0].ObjectID._0_2_ = (undefined2)uVar4;
- }
- else {
- Object::getObjectType(local_3c);
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)(undefined2)local_3c[0].ObjectID;
- uVar7 = iVar6 + 1;
- uVar5 = iVar6 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)(undefined2)local_3c[0].ObjectID >> 8);
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,LIQUIDCONTAINER);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,CONTAINERLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,LIQUIDPOOL);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,POOLLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,CUMULATIVE);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,AMOUNT);
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar4;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- FinishSendData(Connection);
- }
- else {
- error("SendSetInventory: Objekt existiert nicht.\n");
- }
- }
- return;
-}
-
-
-
-void SendDeleteInventory(TConnection *Connection,int Position)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 'y';
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)Position;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-void SendTradeObjects(TConnection *Connection,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- uchar uVar3;
- ulong uVar4;
- uint uVar5;
- uint uVar6;
- Object local_4c [4];
- Object local_3c [4];
- Object local_2c [7];
-
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c[0] = (Object)Obj->ObjectID;
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,DISGUISE);
- if (bVar2) {
- Object::getObjectType(local_3c);
- uVar4 = ObjectType::getAttribute((ObjectType *)local_3c,DISGUISETARGET);
- local_3c[0].ObjectID._0_2_ = (undefined2)uVar4;
- }
- else {
- Object::getObjectType(local_3c);
- }
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar1 % 0x4000] = (uchar)(undefined2)local_3c[0].ObjectID;
- uVar6 = iVar1 + 1;
- uVar5 = iVar1 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar5 = uVar6;
- }
- *(char *)((int)Connection + (uVar6 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)(undefined2)local_3c[0].ObjectID >> 8);
- Connection->NextToWrite = iVar1 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,LIQUIDCONTAINER);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,CONTAINERLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,LIQUIDPOOL);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,POOLLIQUIDTYPE);
- uVar3 = GetLiquidColor(uVar4);
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = uVar3;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,CUMULATIVE);
- if (bVar2) {
- uVar4 = Object::getAttribute(Obj,AMOUNT);
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = (uchar)uVar4;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- }
- Object::getObjectType(local_3c);
- bVar2 = ObjectType::getFlag((ObjectType *)local_3c,CONTAINER);
- if (bVar2) {
- local_4c[0] = (Object)Obj->ObjectID;
- GetFirstContainerObject(local_2c);
- Obj->ObjectID = (ulong)local_2c[0];
- if (local_2c[0].ObjectID != NONE.ObjectID) {
- do {
- local_4c[0] = (Object)Obj->ObjectID;
- local_3c[0].ObjectID = NONE.ObjectID;
- SendTradeObjects(Connection,local_4c);
- Object::getNextObject(local_3c);
- Obj->ObjectID = (ulong)local_3c[0];
- } while (local_3c[0].ObjectID != NONE.ObjectID);
- }
- }
- }
- return;
-}
-
-
-
-void SendTradeOffer(TConnection *Connection,char *Name,bool OwnOffer,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- size_t Length;
- int iVar3;
- uint uVar4;
- uint uVar5;
- char *Text;
- Object local_2c [7];
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = !OwnOffer + '}';
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if (Name == (char *)0x0) {
- Text = "SendTradeOffer: Name ist NULL.\n";
- }
- else {
- Length = strlen(Name);
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,Name,Length);
- }
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c[0] = (Object)Obj->ObjectID;
- iVar3 = CountObjects(local_2c);
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = (uchar)iVar3;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- local_2c[0] = (Object)Obj->ObjectID;
- SendTradeObjects(Connection,local_2c);
- FinishSendData(Connection);
- return;
- }
- Text = "SendTradeOffer: Objekt existiert nicht.\n";
- }
- error(Text);
- }
- return;
-}
-
-
-
-void SendCloseTrade(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = '\x7f';
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-void SendAddField(TConnection *Connection,int x,int y,int z,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- uint uVar3;
- int iVar4;
- uint uVar5;
- Object local_2c [7];
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 'j';
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)x;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 2;
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((uint)x >> 8);
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)y;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 2;
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((uint)y >> 8);
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)z;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c[0] = (Object)Obj->ObjectID;
- SendMapObject(Connection,local_2c);
- FinishSendData(Connection);
- }
- else {
- error(&DAT_08109360);
- }
- }
- return;
-}
-
-
-
-void SendDeleteField(TConnection *Connection,int x,int y,int z,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- uint uVar4;
- int RNum;
- uint uVar5;
- Object local_2c [7];
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 'l';
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)x;
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((uint)x >> 8);
- iVar3 = iVar3 + 2;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)y;
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((uint)y >> 8);
- iVar3 = iVar3 + 2;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)z;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c[0] = (Object)Obj->ObjectID;
- iVar3 = GetObjectRNum(local_2c);
- if (iVar3 < 10) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = (uchar)iVar3;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- }
- }
- else {
- error(&DAT_08109360);
- }
- }
- return;
-}
-
-
-
-void SendChangeField(TConnection *Connection,int x,int y,int z,Object *Obj)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- uint uVar4;
- int RNum;
- uint uVar5;
- Object local_2c [7];
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 'k';
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)x;
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((uint)x >> 8);
- iVar3 = iVar3 + 2;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)y;
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((uint)y >> 8);
- iVar3 = iVar3 + 2;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)z;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- bVar2 = Object::exists(Obj);
- if (bVar2) {
- local_2c[0] = (Object)Obj->ObjectID;
- iVar3 = GetObjectRNum(local_2c);
- if (iVar3 < 10) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = (uchar)iVar3;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- local_2c[0] = (Object)Obj->ObjectID;
- SendMapObject(Connection,local_2c);
- FinishSendData(Connection);
- }
- }
- else {
- error(&DAT_081093a0);
- }
- }
- return;
-}
-
-
-
-void SendMoveCreature(TConnection *Connection,ulong CreatureID,int x,int y,int z)
-
-{
- undefined2 uVar1;
- int iVar2;
- bool bVar3;
- bool bVar4;
- bool bVar5;
- TCreature *pTVar6;
- int iVar7;
- uint uVar8;
- int iVar9;
- uint uVar10;
- TCreature *cr;
- uchar uStack_30;
- bool DestVisible;
- bool StartVisible;
- int RNum;
-
- if (Connection != (TConnection *)0x0) {
- pTVar6 = GetCreature(CreatureID);
- if (pTVar6 == (TCreature *)0x0) {
- error("SendMoveCreature: Kreatur existiert nicht.\n");
- }
- else {
- RNum = (pTVar6->CrObject).ObjectID;
- iVar7 = GetObjectRNum((Object *)&RNum);
- bVar3 = false;
- bVar4 = TConnection::IsVisible(Connection,pTVar6->posx,pTVar6->posy,pTVar6->posz);
- if ((bVar4) && (iVar7 < 10)) {
- bVar3 = true;
- }
- bVar4 = TConnection::IsVisible(Connection,x,y,z);
- if (bVar3) {
- if (bVar4) {
- bVar5 = BeginSendData(Connection);
- if (!bVar5) {
- return;
- }
- iVar2 = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (iVar9 < iVar2 + 0x4000) {
- Connection->OutData[iVar9 % 0x4000] = 'm';
- iVar9 = iVar9 + 1;
- Connection->NextToWrite = iVar9;
- }
- else {
- Connection->Overflow = true;
- }
- uVar1 = (undefined2)pTVar6->posx;
- if (iVar9 < iVar2 + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)uVar1;
- uVar10 = iVar9 + 1;
- uVar8 = iVar9 + 0x4000;
- if (-1 < (int)uVar10) {
- uVar8 = uVar10;
- }
- *(char *)((int)Connection + (uVar10 - (uVar8 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar1 >> 8);
- iVar9 = iVar9 + 2;
- Connection->NextToWrite = iVar9;
- }
- else {
- Connection->Overflow = true;
- }
- uVar1 = (undefined2)pTVar6->posy;
- if (iVar9 < iVar2 + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)uVar1;
- uVar10 = iVar9 + 1;
- uVar8 = iVar9 + 0x4000;
- if (-1 < (int)uVar10) {
- uVar8 = uVar10;
- }
- iVar9 = iVar9 + 2;
- *(char *)((int)Connection + (uVar10 - (uVar8 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar1 >> 8);
- Connection->NextToWrite = iVar9;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar9 < iVar2 + 0x4000) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)pTVar6->posz;
- iVar9 = iVar9 + 1;
- Connection->NextToWrite = iVar9;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar9 < iVar2 + 0x4000) {
- uStack_30 = (uchar)iVar7;
- iVar7 = iVar9 % 0x4000;
- iVar9 = iVar9 + 1;
- Connection->OutData[iVar7] = uStack_30;
- Connection->NextToWrite = iVar9;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar9 < iVar2 + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)x;
- uVar10 = iVar9 + 1;
- uVar8 = iVar9 + 0x4000;
- if (-1 < (int)uVar10) {
- uVar8 = uVar10;
- }
- *(char *)((int)Connection + (uVar10 - (uVar8 & 0xffffc000)) + 0x806) =
- (char)((uint)x >> 8);
- iVar9 = iVar9 + 2;
- Connection->NextToWrite = iVar9;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar9 < iVar2 + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)y;
- uVar10 = iVar9 + 1;
- uVar8 = iVar9 + 0x4000;
- if (-1 < (int)uVar10) {
- uVar8 = uVar10;
- }
- iVar9 = iVar9 + 2;
- *(char *)((int)Connection + (uVar10 - (uVar8 & 0xffffc000)) + 0x806) =
- (char)((uint)y >> 8);
- Connection->NextToWrite = iVar9;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar9 < iVar2 + 0x4000) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)z;
- Connection->NextToWrite = iVar9 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- }
- if (bVar3) {
- if (bVar4) {
- return;
- }
- RNum = (pTVar6->CrObject).ObjectID;
- SendDeleteField(Connection,pTVar6->posx,pTVar6->posy,pTVar6->posz,
- (Object *)&RNum);
- return;
- }
- }
- else if (!bVar4) {
- return;
- }
- if (bVar4) {
- RNum = (pTVar6->CrObject).ObjectID;
- SendAddField(Connection,x,y,z,(Object *)&RNum);
- }
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: y_local
-
-void __regparm2 SendGraphicalEffect(TConnection *Connection,int x,int y,int z,int Type)
-
-{
- int iVar1;
- bool bVar2;
- uint uVar3;
- int iVar4;
- int iVar5;
- uint uVar6;
- undefined1 in_stack_00000010;
- undefined1 in_stack_00000014;
- int Type_local;
- int z_local;
- int y_local;
-
- bVar2 = BeginSendData((TConnection *)y);
- if (bVar2) {
- iVar1 = *(int *)(y + 0x4808);
- iVar4 = *(int *)(y + 0x4810);
- if (iVar4 < iVar1 + 0x4000) {
- *(undefined1 *)(y + 0x806 + iVar4 % 0x4000) = 0x83;
- iVar4 = iVar4 + 1;
- *(int *)(y + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(y + 0x806 + iVar4 % 0x4000) = (char)(z & 0xffffU);
- uVar6 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- iVar4 = iVar4 + 2;
- *(char *)(y + 0x806 + (uVar6 - (uVar3 & 0xffffc000))) = (char)((z & 0xffffU) >> 8);
- *(int *)(y + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(y + 0x806 + iVar4 % 0x4000) = (char)Type;
- uVar6 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- iVar4 = iVar4 + 2;
- *(char *)(y + 0x806 + (uVar6 - (uVar3 & 0xffffc000))) = (char)((uint)Type >> 8);
- *(int *)(y + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x4000) {
- iVar5 = iVar4 % 0x4000;
- iVar4 = iVar4 + 1;
- *(undefined1 *)(y + 0x806 + iVar5) = in_stack_00000010;
- *(int *)(y + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x4000) {
- *(undefined1 *)(y + 0x806 + iVar4 % 0x4000) = in_stack_00000014;
- *(int *)(y + 0x4810) = iVar4 + 1;
- }
- else {
- *(undefined1 *)(y + 0x4814) = 1;
- }
- FinishSendData((TConnection *)y);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: z_local
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void SendTextualEffect(TConnection *Connection,int x,int y,int z,int Color,char *Text)
-
-{
- int iVar1;
- bool bVar2;
- size_t Length;
- uint uVar3;
- int iVar4;
- uint uVar5;
- char *Text_local;
- int Color_local;
- int z_local;
-
- if (Text == (char *)0x0) {
- Connection = (TConnection *)s_SendTextualEffect__Text_ist_NULL_08109460;
- }
- else {
- if (*Text != '\0') {
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 0x84;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(x & 0xffffU);
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 2;
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((x & 0xffffU) >> 8);
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- uVar5 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = (uchar)(y & 0xffffU);
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((y & 0xffffU) >> 8);
- iVar4 = iVar4 + 2;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x4000) {
- Color_local._0_1_ = (uchar)z;
- Connection->OutData[iVar4 % 0x4000] = (uchar)Color_local;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x4000) {
- Text_local._0_1_ = (uchar)Color;
- Connection->OutData[iVar4 % 0x4000] = (uchar)Text_local;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if (Text == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- Length = strlen(Text);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,Text,Length);
- }
- }
- FinishSendData(Connection);
- return;
- }
- return;
- }
- Connection = (TConnection *)s_SendTextualEffect__Text_ist_leer_08109420;
- }
- error((char *)Connection);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: sy_local
-
-void __regparm2
-SendMissileEffect(TConnection *Connection,int sx,int sy,int sz,int zx,int zy,int zz,int Type)
-
-{
- int iVar1;
- bool bVar2;
- uint uVar3;
- int iVar4;
- int iVar5;
- uint uVar6;
- undefined1 in_stack_0000001c;
- undefined1 in_stack_00000020;
- int Type_local;
- int zz_local;
- int zy_local;
- int zx_local;
- int sz_local;
- int sy_local;
-
- bVar2 = BeginSendData((TConnection *)sy);
- if (bVar2) {
- iVar1 = *(int *)(sy + 0x4808);
- iVar4 = *(int *)(sy + 0x4810);
- if (iVar4 < iVar1 + 0x4000) {
- *(undefined1 *)(sy + 0x806 + iVar4 % 0x4000) = 0x85;
- iVar4 = iVar4 + 1;
- *(int *)(sy + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(sy + 0x806 + iVar4 % 0x4000) = (char)(sz & 0xffffU);
- uVar6 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- iVar4 = iVar4 + 2;
- *(char *)(sy + 0x806 + (uVar6 - (uVar3 & 0xffffc000))) = (char)((sz & 0xffffU) >> 8);
- *(int *)(sy + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(sy + 0x806 + iVar4 % 0x4000) = (char)zx;
- uVar6 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- iVar4 = iVar4 + 2;
- *(char *)(sy + 0x806 + (uVar6 - (uVar3 & 0xffffc000))) = (char)((uint)zx >> 8);
- *(int *)(sy + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x4000) {
- zx_local._0_1_ = (undefined1)zy;
- iVar5 = iVar4 % 0x4000;
- iVar4 = iVar4 + 1;
- *(undefined1 *)(sy + 0x806 + iVar5) = (undefined1)zx_local;
- *(int *)(sy + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(sy + 0x806 + iVar4 % 0x4000) = (char)zz;
- uVar6 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- iVar4 = iVar4 + 2;
- *(char *)(sy + 0x806 + (uVar6 - (uVar3 & 0xffffc000))) = (char)((uint)zz >> 8);
- *(int *)(sy + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3fff) {
- *(char *)(sy + 0x806 + iVar4 % 0x4000) = (char)Type;
- uVar6 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- iVar4 = iVar4 + 2;
- *(char *)(sy + 0x806 + (uVar6 - (uVar3 & 0xffffc000))) = (char)((uint)Type >> 8);
- *(int *)(sy + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x4000) {
- iVar5 = iVar4 % 0x4000;
- iVar4 = iVar4 + 1;
- *(undefined1 *)(sy + 0x806 + iVar5) = in_stack_0000001c;
- *(int *)(sy + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x4000) {
- *(undefined1 *)(sy + 0x806 + iVar4 % 0x4000) = in_stack_00000020;
- *(int *)(sy + 0x4810) = iVar4 + 1;
- }
- else {
- *(undefined1 *)(sy + 0x4814) = 1;
- }
- FinishSendData((TConnection *)sy);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Color_local
-
-void __regparm2 SendMarkCreature(TConnection *Connection,ulong CreatureID,int Color)
-
-{
- int iVar1;
- bool bVar2;
- uint uVar3;
- int iVar4;
- uint uVar5;
- undefined4 in_stack_00000008;
- undefined1 in_stack_0000000c;
- int Color_local;
-
- bVar2 = BeginSendData((TConnection *)Color);
- if (bVar2) {
- iVar1 = *(int *)(Color + 0x4808);
- iVar4 = *(int *)(Color + 0x4810);
- if (iVar4 < iVar1 + 0x4000) {
- *(undefined1 *)(Color + 0x806 + iVar4 % 0x4000) = 0x86;
- iVar4 = iVar4 + 1;
- *(int *)(Color + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(Color + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x3ffd) {
- *(char *)(Color + 0x806 + iVar4 % 0x4000) = (char)in_stack_00000008;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)(Color + 0x806 + (uVar5 - (uVar3 & 0xffffc000))) =
- (char)((uint)in_stack_00000008 >> 8);
- uVar5 = iVar4 + 2;
- uVar3 = iVar4 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)(Color + 0x806 + (uVar5 - (uVar3 & 0xffffc000))) =
- (char)((uint)in_stack_00000008 >> 0x10);
- uVar5 = iVar4 + 3;
- uVar3 = iVar4 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 4;
- *(char *)(Color + 0x806 + (uVar5 - (uVar3 & 0xffffc000))) =
- (char)((uint)in_stack_00000008 >> 0x18);
- *(int *)(Color + 0x4810) = iVar4;
- }
- else {
- *(undefined1 *)(Color + 0x4814) = 1;
- }
- if (iVar4 < iVar1 + 0x4000) {
- *(undefined1 *)(Color + 0x806 + iVar4 % 0x4000) = in_stack_0000000c;
- *(int *)(Color + 0x4810) = iVar4 + 1;
- }
- else {
- *(undefined1 *)(Color + 0x4814) = 1;
- }
- FinishSendData((TConnection *)Color);
- return;
- }
- return;
-}
-
-
-
-void SendEditText(TConnection *Connection,Object *Obj)
-
-{
- Object *this;
- bool bVar1;
- TPlayer *pl;
- ulong uVar2;
- size_t sVar3;
- uint uVar4;
- TPlayer *pTVar5;
- int iVar6;
- int iVar7;
- uint uVar8;
- ushort *puVar9;
- char *Text_00;
- uchar local_1060;
- char *local_1048;
- char *Editor;
- char *Text;
- ushort MaxLen;
- char Buffer [4096];
-
- bVar1 = BeginSendData(Connection);
- if (!bVar1) {
- return;
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = 0x96;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- bVar1 = Object::exists(Obj);
- if (!bVar1) {
- Text_00 = &DAT_081094e0;
-LAB_080d1c40:
- error(Text_00);
- return;
- }
- uVar2 = Obj->ObjectID;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3ffd) {
- uVar8 = iVar6 + 1;
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar2;
- uVar4 = iVar6 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) = (char)(uVar2 >> 8);
- uVar8 = iVar6 + 2;
- uVar4 = iVar6 + 0x4001;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) = (char)(uVar2 >> 0x10);
- uVar8 = iVar6 + 3;
- uVar4 = iVar6 + 0x4002;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) = (char)(uVar2 >> 0x18);
- Connection->NextToWrite = iVar6 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- this = (Object *)(Buffer + 0xffc);
- Object::getObjectType(this);
- bVar1 = ObjectType::getFlag((ObjectType *)this,DISGUISE);
- if (bVar1) {
- Object::getObjectType(this);
- uVar2 = ObjectType::getAttribute((ObjectType *)this,DISGUISETARGET);
- Buffer._4092_2_ = (undefined2)uVar2;
- }
- else {
- Object::getObjectType(this);
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x3fff) {
- uVar8 = iVar6 + 1;
- Connection->OutData[iVar6 % 0x4000] = (uchar)Buffer._4092_2_;
- uVar4 = iVar6 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) =
- SUB21(Buffer._4092_2_,1);
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- Editor = (char *)&MaxLen;
- puVar9 = &MaxLen;
- for (iVar6 = 0x400; iVar6 != 0; iVar6 = iVar6 + -1) {
- puVar9[0] = 0;
- puVar9[1] = 0;
- puVar9 = puVar9 + 2;
- }
- Object::getObjectType(this);
- bVar1 = ObjectType::getFlag((ObjectType *)this,WRITE);
- if (bVar1) {
-LAB_080d171d:
- Object::getObjectType(this);
- bVar1 = ObjectType::getFlag((ObjectType *)this,WRITE);
- Object::getObjectType(this);
- uVar2 = ObjectType::getAttribute((ObjectType *)this,!bVar1 + MAXLENGTH);
- Text._0_2_ = (short)uVar2 + -1;
- uVar2 = Object::getAttribute(Obj,TEXTSTRING);
- Editor = GetDynamicString(uVar2);
- uVar2 = Object::getAttribute(Obj,EDITOR);
- local_1048 = GetDynamicString(uVar2);
- }
- else {
- Object::getObjectType(this);
- bVar1 = ObjectType::getFlag((ObjectType *)this,WRITEONCE);
- if (bVar1) goto LAB_080d171d;
- Object::getObjectType(this);
- bVar1 = ObjectType::getFlag((ObjectType *)this,INFORMATION);
- if (bVar1) {
- Object::getObjectType(this);
- uVar2 = ObjectType::getAttribute((ObjectType *)this,INFORMATIONTYPE);
- if (uVar2 != 4) goto LAB_080d1b88;
- pTVar5 = TConnection::GetPlayer(Connection);
- if (pTVar5 == (TPlayer *)0x0) {
- Text_00 = &DAT_081094a0;
- goto LAB_080d1c40;
- }
- GetSpellbook((pTVar5->super_TCreature).ID,Editor);
- local_1048 = (char *)0x0;
- sVar3 = strlen(Editor);
- Text._0_2_ = (short)sVar3;
- }
- else {
-LAB_080d1b88:
- uVar2 = Object::getAttribute(Obj,TEXTSTRING);
- Editor = GetDynamicString(uVar2);
- uVar2 = Object::getAttribute(Obj,EDITOR);
- local_1048 = GetDynamicString(uVar2);
- Text._0_2_ = 0;
- if (Editor != (char *)0x0) {
- sVar3 = strlen(Editor);
- Text._0_2_ = (short)sVar3;
- }
- }
- }
- iVar6 = Connection->NextToSend;
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar6 + 0x3fff) {
- Connection->OutData[iVar7 % 0x4000] = (uchar)Text;
- uVar8 = iVar7 + 1;
- uVar4 = iVar7 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((ushort)(short)Text >> 8);
- Connection->NextToWrite = iVar7 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (Editor != (char *)0x0) {
- if ((short)Text != 0) {
- sVar3 = strlen(Editor);
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar6 + 0x3fff) {
- local_1060 = (uchar)(sVar3 & 0xffff);
- Connection->OutData[iVar7 % 0x4000] = local_1060;
- uVar8 = iVar7 + 1;
- uVar4 = iVar7 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- local_1060 = (uchar)((sVar3 & 0xffff) >> 8);
- *(uchar *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) = local_1060;
- Connection->NextToWrite = iVar7 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar3) {
- SendText(Connection,Editor,sVar3);
- iVar6 = Connection->NextToSend;
- }
- if (local_1048 == (char *)0x0) {
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar6 + 0x3fff) {
- uVar8 = iVar7 + 1;
- uVar4 = iVar7 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- Connection->OutData[iVar7 % 0x4000] = '\0';
- *(undefined1 *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) = 0;
- Connection->NextToWrite = iVar7 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- }
- else {
- sVar3 = strlen(local_1048);
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar6 + 0x3fff) {
- Connection->OutData[iVar7 % 0x4000] = (uchar)(sVar3 & 0xffff);
- uVar8 = iVar7 + 1;
- uVar4 = iVar7 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((sVar3 & 0xffff) >> 8);
- Connection->NextToWrite = iVar7 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar3) {
- SendText(Connection,local_1048,sVar3);
- }
- }
- }
- if (Editor == (char *)0x0) {
- iVar6 = Connection->NextToSend;
- }
- else {
- if ((short)Text != 0) goto LAB_080d1904;
- iVar6 = Connection->NextToSend;
- }
- }
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar6 + 0x3fff) {
- Connection->OutData[iVar7 % 0x4000] = '\0';
- uVar8 = iVar7 + 1;
- uVar4 = iVar7 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) = 0;
- iVar7 = iVar7 + 2;
- Connection->NextToWrite = iVar7;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar7 < iVar6 + 0x3fff) {
- Connection->OutData[iVar7 % 0x4000] = '\0';
- uVar8 = iVar7 + 1;
- uVar4 = iVar7 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar4 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar4 & 0xffffc000)) + 0x806) = 0;
- Connection->NextToWrite = iVar7 + 2;
- }
- else {
- Connection->Overflow = true;
- }
-LAB_080d1904:
- FinishSendData(Connection);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Type_local
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void SendEditList(TConnection *Connection,uchar Type,ulong ID,char *Text)
-
-{
- int iVar1;
- bool bVar2;
- size_t Length;
- uint uVar3;
- int iVar4;
- uint uVar5;
- char *Text_local;
- uchar Type_local;
-
- bVar2 = BeginSendData(Connection);
- if (!bVar2) {
- return;
- }
- iVar1 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 0x97;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = Type;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3ffd) {
- uVar5 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = (uchar)ID;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) = (char)(ID >> 8);
- uVar5 = iVar4 + 2;
- uVar3 = iVar4 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) = (char)(ID >> 0x10);
- uVar5 = iVar4 + 3;
- uVar3 = iVar4 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) = (char)(ID >> 0x18);
- Connection->NextToWrite = iVar4 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- Length = strlen(Text);
- if (Length < 0xfa1) {
- if (Text == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,Text,Length);
- }
- }
- FinishSendData(Connection);
- return;
- }
- error("SendEditList: Text ist zu lang.\n");
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Color
-
-void SendAmbiente(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- uchar local_18 [4];
- int Brightness;
- int Color;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0x82;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- GetAmbiente((int *)local_18,&Brightness);
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = local_18[0];
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)Brightness;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- }
- return;
-}
-
-
-
-void SendCreatureHealth(TConnection *Connection,ulong CreatureID)
-
-{
- bool bVar1;
- TCreature *cr;
- TCreature *this;
- int iVar2;
- int iVar3;
- uint uVar4;
- uint uVar5;
-
- bVar1 = BeginSendData(Connection);
- if (!bVar1) {
- return;
- }
- iVar2 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar2 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0x8c;
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar2 + 0x3ffd) {
- uVar5 = iVar3 + 1;
- Connection->OutData[iVar3 % 0x4000] = (uchar)CreatureID;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 8);
- uVar5 = iVar3 + 2;
- uVar4 = iVar3 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x10);
- uVar5 = iVar3 + 3;
- uVar4 = iVar3 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x18);
- Connection->NextToWrite = iVar3 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- this = GetCreature(CreatureID);
- if (this != (TCreature *)0x0) {
- iVar2 = TCreature::GetHealth(this);
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)iVar2;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- error("SendCreatureHealth: Kreatur %ld existiert nicht.\n");
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: HelpColor
-
-void SendCreatureLight(TConnection *Connection,ulong CreatureID)
-
-{
- int iVar1;
- bool bVar2;
- TCreature *pTVar3;
- int iVar4;
- TCreature *cr;
- uint uVar5;
- int iVar6;
- uint uVar7;
- uchar local_18 [4];
- int HelpBrightness;
- int HelpColor;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 0x8d;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3ffd) {
- uVar7 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = (uchar)CreatureID;
- uVar5 = iVar4 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 8);
- uVar7 = iVar4 + 2;
- uVar5 = iVar4 + 0x4001;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x10);
- uVar7 = iVar4 + 3;
- uVar5 = iVar4 + 0x4002;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x18);
- Connection->NextToWrite = iVar4 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar3 = GetCreature(CreatureID);
- if (pTVar3 == (TCreature *)0x0) {
- error("SendCreatureLight: Kreatur %ld existiert nicht.\n",CreatureID);
- }
- else {
- GetCreatureLight(pTVar3->ID,(int *)local_18,&HelpBrightness);
- iVar1 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- iVar6 = iVar4 % 0x4000;
- iVar4 = iVar4 + 1;
- Connection->OutData[iVar6] = local_18[0];
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)HelpBrightness;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- }
- }
- return;
-}
-
-
-
-void SendCreatureOutfit(TConnection *Connection,ulong CreatureID)
-
-{
- undefined2 uVar1;
- ushort uVar2;
- int iVar3;
- bool bVar4;
- TCreature *pTVar5;
- uint uVar6;
- int iVar7;
- TCreature *cr;
- uint uVar8;
-
- bVar4 = BeginSendData(Connection);
- if (!bVar4) {
- return;
- }
- iVar3 = Connection->NextToSend;
- iVar7 = Connection->NextToWrite;
- if (iVar7 < iVar3 + 0x4000) {
- Connection->OutData[iVar7 % 0x4000] = 0x8e;
- iVar7 = iVar7 + 1;
- Connection->NextToWrite = iVar7;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar7 < iVar3 + 0x3ffd) {
- uVar8 = iVar7 + 1;
- Connection->OutData[iVar7 % 0x4000] = (uchar)CreatureID;
- uVar6 = iVar7 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar6 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar6 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 8);
- uVar8 = iVar7 + 2;
- uVar6 = iVar7 + 0x4001;
- if (-1 < (int)uVar8) {
- uVar6 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar6 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x10);
- uVar8 = iVar7 + 3;
- uVar6 = iVar7 + 0x4002;
- if (-1 < (int)uVar8) {
- uVar6 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar6 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x18);
- Connection->NextToWrite = iVar7 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar5 = GetCreature(CreatureID);
- if (pTVar5 != (TCreature *)0x0) {
- uVar1 = (undefined2)(pTVar5->Outfit).OutfitID;
- iVar7 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar7 + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)uVar1;
- uVar8 = iVar3 + 1;
- uVar6 = iVar3 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar6 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar6 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar1 >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if ((pTVar5->Outfit).OutfitID == 0) {
- uVar2 = (pTVar5->Outfit).field_1.ObjectType;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar7 + 0x3fff) {
- uVar8 = iVar3 + 1;
- Connection->OutData[iVar3 % 0x4000] = (uchar)uVar2;
- uVar6 = iVar3 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar6 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar6 & 0xffffc000)) + 0x806) =
- (char)(uVar2 >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- }
- else {
- SendText(Connection,(char *)(pTVar5->Outfit).field_1.Colors,4);
- }
- FinishSendData(Connection);
- return;
- }
- error("SendCreatureOutfit: Kreatur %ld existiert nicht.\n");
- return;
-}
-
-
-
-void SendCreatureSpeed(TConnection *Connection,ulong CreatureID)
-
-{
- int iVar1;
- bool bVar2;
- TCreature *cr;
- TCreature *this;
- uint uVar3;
- int iVar4;
- uint uVar5;
- uint uVar6;
-
- bVar2 = BeginSendData(Connection);
- if (!bVar2) {
- return;
- }
- iVar1 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < iVar1 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 0x8f;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < iVar1 + 0x3ffd) {
- uVar6 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = (uchar)CreatureID;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- *(char *)((int)Connection + (uVar6 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 8);
- uVar6 = iVar4 + 2;
- uVar3 = iVar4 + 0x4001;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- *(char *)((int)Connection + (uVar6 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x10);
- uVar6 = iVar4 + 3;
- uVar3 = iVar4 + 0x4002;
- if (-1 < (int)uVar6) {
- uVar3 = uVar6;
- }
- *(char *)((int)Connection + (uVar6 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x18);
- Connection->NextToWrite = iVar4 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- this = GetCreature(CreatureID);
- if (this != (TCreature *)0x0) {
- uVar3 = TCreature::GetSpeed(this);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(uVar3 & 0xffff);
- uVar5 = iVar4 + 1;
- uVar6 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar6 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar6 & 0xffffc000)) + 0x806) =
- (char)((uVar3 & 0xffff) >> 8);
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- error("SendCreatureSpeed: Kreatur %ld existiert nicht.\n");
- return;
-}
-
-
-
-void SendCreatureSkull(TConnection *Connection,ulong CreatureID)
-
-{
- bool bVar1;
- TPlayer *this;
- TPlayer *Observer;
- int iVar2;
- int iVar3;
- uint uVar4;
- TPlayer *pl;
- uint uVar5;
-
- bVar1 = BeginSendData(Connection);
- if (!bVar1) {
- return;
- }
- iVar2 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar2 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0x90;
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar2 + 0x3ffd) {
- uVar5 = iVar3 + 1;
- Connection->OutData[iVar3 % 0x4000] = (uchar)CreatureID;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 8);
- uVar5 = iVar3 + 2;
- uVar4 = iVar3 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x10);
- uVar5 = iVar3 + 3;
- uVar4 = iVar3 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x18);
- Connection->NextToWrite = iVar3 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- this = GetPlayer(CreatureID);
- if (this != (TPlayer *)0x0) {
- Observer = TConnection::GetPlayer(Connection);
- iVar2 = TPlayer::GetPlayerkillingMark(this,Observer);
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)iVar2;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- error("SendCreatureSkull: Kreatur %ld existiert nicht.\n");
- return;
-}
-
-
-
-void SendCreatureParty(TConnection *Connection,ulong CreatureID)
-
-{
- bool bVar1;
- TPlayer *this;
- TPlayer *Observer;
- int iVar2;
- int iVar3;
- uint uVar4;
- TPlayer *pl;
- uint uVar5;
-
- bVar1 = BeginSendData(Connection);
- if (!bVar1) {
- return;
- }
- iVar2 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar2 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0x91;
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar2 + 0x3ffd) {
- uVar5 = iVar3 + 1;
- Connection->OutData[iVar3 % 0x4000] = (uchar)CreatureID;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 8);
- uVar5 = iVar3 + 2;
- uVar4 = iVar3 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x10);
- uVar5 = iVar3 + 3;
- uVar4 = iVar3 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)(CreatureID >> 0x18);
- Connection->NextToWrite = iVar3 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- this = GetPlayer(CreatureID);
- if (this != (TPlayer *)0x0) {
- Observer = TConnection::GetPlayer(Connection);
- iVar2 = TPlayer::GetPartyMark(this,Observer);
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)iVar2;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- error("SendCreatureParty: Kreatur %ld existiert nicht.\n");
- return;
-}
-
-
-
-void SendClearTarget(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = 0xa3;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: pl
-
-void SendPlayerData(TConnection *Connection)
-
-{
- undefined2 uVar1;
- TSkill *pTVar2;
- bool bVar3;
- TPlayer *pTVar4;
- uint uVar5;
- int iVar6;
- uint uVar7;
- TSkill *sk;
- int Capacity;
- uint uVar8;
- int iVar9;
- int local_1c;
- TPlayer *pl;
-
- bVar3 = BeginSendData(Connection);
- if (!bVar3) {
- return;
- }
- iVar9 = Connection->NextToWrite;
- if (iVar9 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar9 % 0x4000] = 0xa0;
- Connection->NextToWrite = iVar9 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar4 = TConnection::GetPlayer(Connection);
- if (pTVar4 == (TPlayer *)0x0) {
- error(&DAT_081096e0);
- return;
- }
- pTVar2 = (pTVar4->super_TCreature).super_TSkillBase.Skills[2];
- if (pTVar2 == (TSkill *)0x0) {
- local_1c = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (local_1c + 0x3fff <= iVar9) goto LAB_080d3570;
- Connection->OutData[iVar9 % 0x4000] = '\0';
- uVar8 = iVar9 + 1;
- uVar5 = iVar9 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
-LAB_080d2d93:
- iVar9 = iVar9 + 2;
- Connection->NextToWrite = iVar9;
- }
- else {
- uVar5 = TSkill::Get(pTVar2);
- local_1c = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (iVar9 < local_1c + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)(uVar5 & 0xffff);
- uVar7 = iVar9 + 1;
- uVar8 = iVar9 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar8 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar8 & 0xffffc000)) + 0x806) =
- (char)((uVar5 & 0xffff) >> 8);
- goto LAB_080d2d93;
- }
-LAB_080d3570:
- Connection->Overflow = true;
- }
- if (pTVar2 == (TSkill *)0x0) {
- if (local_1c + 0x3fff <= iVar9) goto LAB_080d3510;
- Connection->OutData[iVar9 % 0x4000] = '\0';
- uVar8 = iVar9 + 1;
- uVar5 = iVar9 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
-LAB_080d2df5:
- Connection->NextToWrite = iVar9 + 2;
- }
- else {
- uVar1 = (undefined2)pTVar2->Max;
- if (iVar9 < local_1c + 0x3fff) {
- uVar8 = iVar9 + 1;
- Connection->OutData[iVar9 % 0x4000] = (uchar)uVar1;
- uVar5 = iVar9 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar1 >> 8);
- goto LAB_080d2df5;
- }
-LAB_080d3510:
- Connection->Overflow = true;
- }
- iVar9 = 0;
- pTVar2 = (pTVar4->super_TCreature).super_TSkillBase.Skills[5];
- if (pTVar2 != (TSkill *)0x0) {
- iVar6 = TSkill::Get(pTVar2);
- iVar9 = GetInventoryWeight((pTVar4->super_TCreature).ID);
- iVar9 = iVar6 * 100 - iVar9;
- }
- if (iVar9 < 0) {
- iVar9 = 0;
- }
- bVar3 = CheckRight((pTVar4->super_TCreature).ID,ZERO_CAPACITY);
- if (bVar3) {
- iVar9 = 0;
- }
- local_1c = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- uVar5 = iVar9 / 100 & 0xffff;
- if (iVar6 < local_1c + 0x3fff) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)uVar5;
- uVar7 = iVar6 + 1;
- uVar8 = iVar6 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar8 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar8 & 0xffffc000)) + 0x806) = (char)(uVar5 >> 8);
- iVar6 = iVar6 + 2;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar2 = (pTVar4->super_TCreature).super_TSkillBase.Skills[0];
- if (pTVar2 == (TSkill *)0x0) {
- if (local_1c + 0x3ffd <= iVar6) goto LAB_080d3425;
- uVar8 = iVar6 + 1;
- Connection->OutData[iVar6 % 0x4000] = '\0';
- uVar5 = iVar6 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
- uVar8 = iVar6 + 2;
- uVar5 = iVar6 + 0x4001;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
- uVar8 = iVar6 + 3;
- uVar5 = iVar6 + 0x4002;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
-LAB_080d2f38:
- Connection->NextToWrite = iVar6 + 4;
- }
- else {
- iVar9 = pTVar2->Exp;
- if (iVar6 < local_1c + 0x3ffd) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar9;
- uVar8 = iVar6 + 1;
- uVar5 = iVar6 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((uint)iVar9 >> 8);
- uVar8 = iVar6 + 2;
- uVar5 = iVar6 + 0x4001;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((uint)iVar9 >> 0x10);
- uVar8 = iVar6 + 3;
- uVar5 = iVar6 + 0x4002;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((uint)iVar9 >> 0x18);
- goto LAB_080d2f38;
- }
-LAB_080d3425:
- Connection->Overflow = true;
- }
- if (pTVar2 == (TSkill *)0x0) {
- iVar9 = Connection->NextToWrite;
- if (local_1c + 0x3fff <= iVar9) goto LAB_080d33c6;
- uVar8 = iVar9 + 1;
- Connection->OutData[iVar9 % 0x4000] = '\0';
- uVar5 = iVar9 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
-LAB_080d2fb2:
- Connection->NextToWrite = iVar9 + 2;
- }
- else {
- uVar5 = TSkill::Get(pTVar2);
- local_1c = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (iVar9 < local_1c + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)(uVar5 & 0xffff);
- uVar7 = iVar9 + 1;
- uVar8 = iVar9 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar8 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar8 & 0xffffc000)) + 0x806) =
- (char)((uVar5 & 0xffff) >> 8);
- goto LAB_080d2fb2;
- }
-LAB_080d33c6:
- Connection->Overflow = true;
- }
- if (pTVar2 == (TSkill *)0x0) {
- iVar9 = Connection->NextToWrite;
- if (local_1c + 0x4000 <= iVar9) goto LAB_080d3383;
- Connection->OutData[iVar9 % 0x4000] = '\0';
-LAB_080d3009:
- Connection->NextToWrite = iVar9 + 1;
- }
- else {
- iVar6 = TSkill::GetProgress(pTVar2);
- local_1c = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (iVar9 < local_1c + 0x4000) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)iVar6;
- goto LAB_080d3009;
- }
-LAB_080d3383:
- Connection->Overflow = true;
- }
- pTVar2 = (pTVar4->super_TCreature).super_TSkillBase.Skills[3];
- if (pTVar2 == (TSkill *)0x0) {
- iVar9 = Connection->NextToWrite;
- if (local_1c + 0x3fff <= iVar9) goto LAB_080d3321;
- uVar8 = iVar9 + 1;
- Connection->OutData[iVar9 % 0x4000] = '\0';
- uVar5 = iVar9 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
-LAB_080d3086:
- iVar9 = iVar9 + 2;
- Connection->NextToWrite = iVar9;
- }
- else {
- uVar5 = TSkill::Get(pTVar2);
- local_1c = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (iVar9 < local_1c + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)(uVar5 & 0xffff);
- uVar7 = iVar9 + 1;
- uVar8 = iVar9 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar8 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar8 & 0xffffc000)) + 0x806) =
- (char)((uVar5 & 0xffff) >> 8);
- goto LAB_080d3086;
- }
-LAB_080d3321:
- Connection->Overflow = true;
- }
- if (pTVar2 == (TSkill *)0x0) {
- if (local_1c + 0x3fff <= iVar9) goto LAB_080d32c8;
- uVar8 = iVar9 + 1;
- Connection->OutData[iVar9 % 0x4000] = '\0';
- uVar5 = iVar9 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(undefined1 *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) = 0;
-LAB_080d30e8:
- Connection->NextToWrite = iVar9 + 2;
- }
- else {
- uVar1 = (undefined2)pTVar2->Max;
- if (iVar9 < local_1c + 0x3fff) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)uVar1;
- uVar8 = iVar9 + 1;
- uVar5 = iVar9 + 0x4000;
- if (-1 < (int)uVar8) {
- uVar5 = uVar8;
- }
- *(char *)((int)Connection + (uVar8 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar1 >> 8);
- goto LAB_080d30e8;
- }
-LAB_080d32c8:
- Connection->Overflow = true;
- }
- pTVar2 = (pTVar4->super_TCreature).super_TSkillBase.Skills[1];
- if (pTVar2 == (TSkill *)0x0) {
- iVar9 = Connection->NextToWrite;
- if (local_1c + 0x4000 <= iVar9) goto LAB_080d3286;
- Connection->OutData[iVar9 % 0x4000] = '\0';
-LAB_080d3143:
- Connection->NextToWrite = iVar9 + 1;
- }
- else {
- iVar6 = TSkill::Get(pTVar2);
- local_1c = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (iVar9 < local_1c + 0x4000) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)iVar6;
- goto LAB_080d3143;
- }
-LAB_080d3286:
- Connection->Overflow = true;
- }
- if (pTVar2 == (TSkill *)0x0) {
- iVar9 = Connection->NextToWrite;
- if (local_1c + 0x4000 <= iVar9) goto LAB_080d3243;
- Connection->OutData[iVar9 % 0x4000] = '\0';
-LAB_080d319a:
- Connection->NextToWrite = iVar9 + 1;
- }
- else {
- iVar6 = TSkill::GetProgress(pTVar2);
- local_1c = Connection->NextToSend;
- iVar9 = Connection->NextToWrite;
- if (iVar9 < local_1c + 0x4000) {
- Connection->OutData[iVar9 % 0x4000] = (uchar)iVar6;
- goto LAB_080d319a;
- }
-LAB_080d3243:
- Connection->Overflow = true;
- }
- pTVar2 = (pTVar4->super_TCreature).super_TSkillBase.Skills[0x16];
- if (pTVar2 == (TSkill *)0x0) {
- iVar9 = Connection->NextToWrite;
- if (local_1c + 0x4000 <= iVar9) goto LAB_080d3201;
- Connection->OutData[iVar9 % 0x4000] = '\0';
- }
- else {
- iVar6 = TSkill::Get(pTVar2);
- iVar9 = Connection->NextToWrite;
- if (Connection->NextToSend + 0x4000 <= iVar9) {
-LAB_080d3201:
- Connection->Overflow = true;
- goto LAB_080d31f2;
- }
- Connection->OutData[iVar9 % 0x4000] = (uchar)iVar6;
- }
- Connection->NextToWrite = iVar9 + 1;
-LAB_080d31f2:
- FinishSendData(Connection);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: pl
-
-void SendPlayerSkills(TConnection *Connection)
-
-{
- TSkill *pTVar1;
- bool bVar2;
- TPlayer *pTVar3;
- int iVar4;
- int iVar5;
- int iVar6;
- TSkill *sk;
- uchar local_18;
- TPlayer *pl;
-
- bVar2 = BeginSendData(Connection);
- if (!bVar2) {
- return;
- }
- iVar6 = Connection->NextToWrite;
- if (iVar6 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = 0xa1;
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar3 = TConnection::GetPlayer(Connection);
- if (pTVar3 == (TPlayer *)0x0) {
- error(&DAT_08109720);
- return;
- }
- pTVar1 = (pTVar3->super_TCreature).super_TSkillBase.Skills[0xb];
- if (pTVar1 == (TSkill *)0x0) {
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3e93;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d36d2:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::Get(pTVar1);
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar5 + 0x4000) {
- local_18 = (uchar)iVar4;
- Connection->OutData[iVar6 % 0x4000] = local_18;
- goto LAB_080d36d2;
- }
-LAB_080d3e93:
- Connection->Overflow = true;
- }
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3e52;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3725:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::GetProgress(pTVar1);
- iVar6 = Connection->NextToWrite;
- iVar5 = Connection->NextToSend;
- if (iVar6 < iVar5 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar4;
- goto LAB_080d3725;
- }
-LAB_080d3e52:
- Connection->Overflow = true;
- }
- pTVar1 = (pTVar3->super_TCreature).super_TSkillBase.Skills[9];
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3e13;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3781:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::Get(pTVar1);
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar5 + 0x4000) {
- local_18 = (uchar)iVar4;
- Connection->OutData[iVar6 % 0x4000] = local_18;
- goto LAB_080d3781;
- }
-LAB_080d3e13:
- Connection->Overflow = true;
- }
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3dd2;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d37d4:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::GetProgress(pTVar1);
- iVar6 = Connection->NextToWrite;
- iVar5 = Connection->NextToSend;
- if (iVar6 < iVar5 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar4;
- goto LAB_080d37d4;
- }
-LAB_080d3dd2:
- Connection->Overflow = true;
- }
- pTVar1 = (pTVar3->super_TCreature).super_TSkillBase.Skills[8];
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3d93;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3830:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::Get(pTVar1);
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar5 + 0x4000) {
- local_18 = (uchar)iVar4;
- Connection->OutData[iVar6 % 0x4000] = local_18;
- goto LAB_080d3830;
- }
-LAB_080d3d93:
- Connection->Overflow = true;
- }
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3d52;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3883:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::GetProgress(pTVar1);
- iVar6 = Connection->NextToWrite;
- iVar5 = Connection->NextToSend;
- if (iVar6 < iVar5 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar4;
- goto LAB_080d3883;
- }
-LAB_080d3d52:
- Connection->Overflow = true;
- }
- pTVar1 = (pTVar3->super_TCreature).super_TSkillBase.Skills[10];
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3d13;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d38df:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::Get(pTVar1);
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar5 + 0x4000) {
- local_18 = (uchar)iVar4;
- Connection->OutData[iVar6 % 0x4000] = local_18;
- goto LAB_080d38df;
- }
-LAB_080d3d13:
- Connection->Overflow = true;
- }
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3cd2;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3932:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::GetProgress(pTVar1);
- iVar6 = Connection->NextToWrite;
- iVar5 = Connection->NextToSend;
- if (iVar6 < iVar5 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar4;
- goto LAB_080d3932;
- }
-LAB_080d3cd2:
- Connection->Overflow = true;
- }
- pTVar1 = (pTVar3->super_TCreature).super_TSkillBase.Skills[7];
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3c93;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d398e:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::Get(pTVar1);
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar5 + 0x4000) {
- local_18 = (uchar)iVar4;
- Connection->OutData[iVar6 % 0x4000] = local_18;
- goto LAB_080d398e;
- }
-LAB_080d3c93:
- Connection->Overflow = true;
- }
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3c52;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d39e1:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::GetProgress(pTVar1);
- iVar6 = Connection->NextToWrite;
- iVar5 = Connection->NextToSend;
- if (iVar6 < iVar5 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar4;
- goto LAB_080d39e1;
- }
-LAB_080d3c52:
- Connection->Overflow = true;
- }
- pTVar1 = (pTVar3->super_TCreature).super_TSkillBase.Skills[6];
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3c13;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3a3d:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::Get(pTVar1);
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar5 + 0x4000) {
- local_18 = (uchar)iVar4;
- Connection->OutData[iVar6 % 0x4000] = local_18;
- goto LAB_080d3a3d;
- }
-LAB_080d3c13:
- Connection->Overflow = true;
- }
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3bd2;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3a90:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::GetProgress(pTVar1);
- iVar6 = Connection->NextToWrite;
- iVar5 = Connection->NextToSend;
- if (iVar6 < iVar5 + 0x4000) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar4;
- goto LAB_080d3a90;
- }
-LAB_080d3bd2:
- Connection->Overflow = true;
- }
- pTVar1 = (pTVar3->super_TCreature).super_TSkillBase.Skills[0xd];
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3b91;
- Connection->OutData[iVar6 % 0x4000] = '\0';
-LAB_080d3aec:
- Connection->NextToWrite = iVar6 + 1;
- }
- else {
- iVar4 = TSkill::Get(pTVar1);
- iVar5 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar5 + 0x4000) {
- local_18 = (uchar)iVar4;
- Connection->OutData[iVar6 % 0x4000] = local_18;
- goto LAB_080d3aec;
- }
-LAB_080d3b91:
- Connection->Overflow = true;
- }
- if (pTVar1 == (TSkill *)0x0) {
- iVar6 = Connection->NextToWrite;
- if (iVar5 + 0x4000 <= iVar6) goto LAB_080d3b50;
- Connection->OutData[iVar6 % 0x4000] = '\0';
- }
- else {
- iVar5 = TSkill::GetProgress(pTVar1);
- iVar6 = Connection->NextToWrite;
- if (Connection->NextToSend + 0x4000 <= iVar6) {
-LAB_080d3b50:
- Connection->Overflow = true;
- goto LAB_080d3b3e;
- }
- Connection->OutData[iVar6 % 0x4000] = (uchar)iVar5;
- }
- Connection->NextToWrite = iVar6 + 1;
-LAB_080d3b3e:
- FinishSendData(Connection);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: State_local
-
-void SendPlayerState(TConnection *Connection,uchar State)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- uchar State_local;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0xa2;
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = State;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-void SendMessage(TConnection *Connection,int Mode,char *Text,...)
-
-{
- int iVar1;
- bool bVar2;
- size_t Length;
- uint uVar3;
- uint uVar4;
- int iVar5;
- int iVar6;
- char local_101c [4];
- char Buffer [4096];
-
- if (Mode - 0x12U < 6) {
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- vsnprintf(local_101c,0x1000,Text,&stack0x00000010);
- iVar1 = Connection->NextToSend;
- iVar6 = Connection->NextToWrite;
- if (iVar6 < iVar1 + 0x4000) {
- iVar5 = iVar6 % 0x4000;
- iVar6 = iVar6 + 1;
- Connection->OutData[iVar5] = 0xb4;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar6 < iVar1 + 0x4000) {
- iVar5 = iVar6 % 0x4000;
- iVar6 = iVar6 + 1;
- Connection->OutData[iVar5] = (uchar)Mode;
- Connection->NextToWrite = iVar6;
- }
- else {
- Connection->Overflow = true;
- }
- Length = strlen(local_101c);
- if (iVar6 < iVar1 + 0x3fff) {
- Connection->OutData[iVar6 % 0x4000] = (uchar)(Length & 0xffff);
- uVar4 = iVar6 + 1;
- uVar3 = iVar6 + 0x4000;
- if (-1 < (int)uVar4) {
- uVar3 = uVar4;
- }
- *(char *)((int)Connection + (uVar4 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar6 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,local_101c,Length);
- }
- FinishSendData(Connection);
- }
- }
- else {
- error(&DAT_08109760,Mode);
- }
- return;
-}
-
-
-
-void SendSnapback(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
- TPlayer *pl;
- TPlayer *pTVar3;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = 0xb5;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar3 = TConnection::GetPlayer(Connection);
- if (pTVar3 != (TPlayer *)0x0) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = (uchar)(pTVar3->super_TCreature).Direction;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Sender_local
-
-void SendTalk(TConnection *Connection,ulong StatementID,char *Sender,int Mode,char *Text,int Data)
-
-{
- bool bVar1;
- size_t sVar2;
- uint uVar3;
- int iVar4;
- uint uVar5;
- int local_28;
- uchar local_24;
- uchar local_1c;
- int Data_local;
- char *Text_local;
- char *Sender_local;
-
- if ((((Mode != 4) && (Mode != 7)) && (Mode != 8)) &&
- (((Mode != 6 && (Mode != 0xb)) && (Mode != 9)))) {
- error(&DAT_081097c0);
- return;
- }
- if (Sender == (char *)0x0) {
- Connection = (TConnection *)s_SendTalk______Sender_ist_NULL__081097a0;
- }
- else {
- if (Text != (char *)0x0) {
- bVar1 = BeginSendData(Connection);
- if (bVar1) {
- local_28 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_28 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 0xaa;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < local_28 + 0x3ffd) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)StatementID;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(StatementID >> 8);
- uVar5 = iVar4 + 2;
- uVar3 = iVar4 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(StatementID >> 0x10);
- uVar5 = iVar4 + 3;
- uVar3 = iVar4 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(StatementID >> 0x18);
- Connection->NextToWrite = iVar4 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- if (Sender == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- local_28 = Connection->NextToSend;
- }
- else {
- sVar2 = strlen(Sender);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_28 + 0x3fff) {
- local_24 = (uchar)(sVar2 & 0xffff);
- Connection->OutData[iVar4 % 0x4000] = local_24;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- local_24 = (uchar)((sVar2 & 0xffff) >> 8);
- *(uchar *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- local_24;
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar2) {
- SendText(Connection,Sender,sVar2);
- local_28 = Connection->NextToSend;
- }
- }
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_28 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)Mode;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if (Mode == 6) {
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_28 + 0x3ffd) {
- local_1c = (uchar)Data;
- uVar5 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = local_1c;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- local_1c = (uchar)((uint)Data >> 8);
- *(uchar *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- local_1c;
- uVar5 = iVar4 + 2;
- uVar3 = iVar4 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- local_1c = (uchar)((uint)Data >> 0x10);
- *(uchar *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- local_1c;
- uVar5 = iVar4 + 3;
- uVar3 = iVar4 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- local_1c = (uchar)((uint)Data >> 0x18);
- Connection->NextToWrite = iVar4 + 4;
- *(uchar *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- local_1c;
- }
- else {
- Connection->Overflow = true;
- }
- }
- if (Text == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- sVar2 = strlen(Text);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_28 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(sVar2 & 0xffff);
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((sVar2 & 0xffff) >> 8);
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar2) {
- SendText(Connection,Text,sVar2);
- }
- }
- FinishSendData(Connection);
- return;
- }
- return;
- }
- Connection = (TConnection *)s_SendTalk______Text_ist_NULL__08109deb;
- }
- error((char *)Connection);
- return;
-}
-
-
-
-// WARNING: Removing unreachable block (ram,0x080d4a56)
-// WARNING: Variable defined which should be unmapped: Sender_local
-
-void __regparm2
-SendTalk(TConnection *Connection,ulong StatementID,char *Sender,int Mode,int Channel,char *Text)
-
-{
- bool bVar1;
- size_t sVar2;
- uint uVar3;
- int iVar4;
- uint uVar5;
- int iVar6;
- undefined2 in_stack_00000014;
- char *in_stack_00000018;
- int local_2c;
- char local_28;
- char local_24;
- char *Text_local;
- int Channel_local;
- char *Sender_local;
-
- if ((((Text != (char *)0x5) && (Text != (char *)0xa)) && (Text != (char *)0xc)) &&
- (Text != (char *)0xe)) {
- error(&DAT_08109820);
- return;
- }
- if (Channel == 0) {
- Sender = "SendTalk (C): Sender ist NULL.\n";
- }
- else {
- if (in_stack_00000018 != (char *)0x0) {
- bVar1 = BeginSendData((TConnection *)Sender);
- if (!bVar1) {
- return;
- }
- local_2c = *(int *)(Sender + 0x4808);
- iVar4 = *(int *)(Sender + 0x4810);
- if (iVar4 < local_2c + 0x4000) {
- Sender[iVar4 % 0x4000 + 0x806] = -0x56;
- iVar4 = iVar4 + 1;
- *(int *)(Sender + 0x4810) = iVar4;
- }
- else {
- Sender[0x4814] = '\x01';
- }
- if (iVar4 < local_2c + 0x3ffd) {
- Sender[iVar4 % 0x4000 + 0x806] = (char)Mode;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- Sender[(uVar5 - (uVar3 & 0xffffc000)) + 0x806] = (char)((uint)Mode >> 8);
- uVar5 = iVar4 + 2;
- uVar3 = iVar4 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- Sender[(uVar5 - (uVar3 & 0xffffc000)) + 0x806] = (char)((uint)Mode >> 0x10);
- uVar5 = iVar4 + 3;
- uVar3 = iVar4 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- Sender[(uVar5 - (uVar3 & 0xffffc000)) + 0x806] = (char)((uint)Mode >> 0x18);
- *(int *)(Sender + 0x4810) = iVar4 + 4;
- }
- else {
- Sender[0x4814] = '\x01';
- }
- if (Text == (char *)0xe) {
- sVar2 = strlen("");
- iVar4 = *(int *)(Sender + 0x4810);
- if (iVar4 < local_2c + 0x3fff) {
- local_24 = (char)(sVar2 & 0xffff);
- Sender[iVar4 % 0x4000 + 0x806] = local_24;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- local_24 = (char)((sVar2 & 0xffff) >> 8);
- Sender[(uVar5 - (uVar3 & 0xffffc000)) + 0x806] = local_24;
- *(int *)(Sender + 0x4810) = iVar4 + 2;
- }
- else {
- Sender[0x4814] = '\x01';
- }
- if (0 < (int)sVar2) {
- SendText((TConnection *)Sender,"",sVar2);
- local_2c = *(int *)(Sender + 0x4808);
- }
- }
- else {
- if (Channel == 0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- sVar2 = strlen((char *)Channel);
- iVar4 = *(int *)(Sender + 0x4810);
- if (iVar4 < local_2c + 0x3fff) {
- local_28 = (char)(sVar2 & 0xffff);
- Sender[iVar4 % 0x4000 + 0x806] = local_28;
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- local_28 = (char)((sVar2 & 0xffff) >> 8);
- Sender[(uVar5 - (uVar3 & 0xffffc000)) + 0x806] = local_28;
- *(int *)(Sender + 0x4810) = iVar4 + 2;
- }
- else {
- Sender[0x4814] = '\x01';
- }
- if ((int)sVar2 < 1) goto LAB_080d47d5;
- SendText((TConnection *)Sender,(char *)Channel,sVar2);
- }
- local_2c = *(int *)(Sender + 0x4808);
- }
-LAB_080d47d5:
- iVar4 = *(int *)(Sender + 0x4810);
- if (iVar4 < local_2c + 0x4000) {
- iVar6 = iVar4 % 0x4000;
- iVar4 = iVar4 + 1;
- Sender[iVar6 + 0x806] = (char)Text;
- *(int *)(Sender + 0x4810) = iVar4;
- }
- else {
- Sender[0x4814] = '\x01';
- }
- if (iVar4 < local_2c + 0x3fff) {
- uVar5 = iVar4 + 1;
- Sender[iVar4 % 0x4000 + 0x806] = (char)in_stack_00000014;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- Sender[(uVar5 - (uVar3 & 0xffffc000)) + 0x806] =
- (char)((ushort)in_stack_00000014 >> 8);
- *(int *)(Sender + 0x4810) = iVar4 + 2;
- }
- else {
- Sender[0x4814] = '\x01';
- }
- if (in_stack_00000018 == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- sVar2 = strlen(in_stack_00000018);
- iVar4 = *(int *)(Sender + 0x4810);
- if (iVar4 < local_2c + 0x3fff) {
- Sender[iVar4 % 0x4000 + 0x806] = (char)(sVar2 & 0xffff);
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- Sender[(uVar5 - (uVar3 & 0xffffc000)) + 0x806] = (char)((sVar2 & 0xffff) >> 8);
- *(int *)(Sender + 0x4810) = iVar4 + 2;
- }
- else {
- Sender[0x4814] = '\x01';
- }
- if (0 < (int)sVar2) {
- SendText((TConnection *)Sender,in_stack_00000018,sVar2);
- }
- }
- FinishSendData((TConnection *)Sender);
- return;
- }
- Sender = "SendTalk (C): Text ist NULL.\n";
- }
- error(Sender);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Sender_local
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void SendTalk(TConnection *Connection,ulong StatementID,char *Sender,int Mode,int x,int y,int z,
- char *Text)
-
-{
- bool bVar1;
- size_t sVar2;
- uint uVar3;
- int iVar4;
- uint uVar5;
- int local_30;
- char *Text_local;
- int z_local;
- int y_local;
- int x_local;
- int Mode_local;
- char *Sender_local;
-
- if (((2 < Mode - 1U) && (Mode != 0x10)) && (Mode != 0x11)) {
- error(&DAT_08109880);
- return;
- }
- if (Sender == (char *)0x0) {
- Connection = (TConnection *)s_SendTalk__K___Sender_ist_NULL__08109860;
- }
- else {
- if (Text != (char *)0x0) {
- bVar1 = BeginSendData(Connection);
- if (bVar1) {
- local_30 = Connection->NextToSend;
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_30 + 0x4000) {
- Connection->OutData[iVar4 % 0x4000] = 0xaa;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < local_30 + 0x3ffd) {
- uVar5 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = (uchar)StatementID;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(StatementID >> 8);
- uVar5 = iVar4 + 2;
- uVar3 = iVar4 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(StatementID >> 0x10);
- uVar5 = iVar4 + 3;
- uVar3 = iVar4 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(StatementID >> 0x18);
- Connection->NextToWrite = iVar4 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- if (Sender == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- local_30 = Connection->NextToSend;
- }
- else {
- sVar2 = strlen(Sender);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_30 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(sVar2 & 0xffff);
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((sVar2 & 0xffff) >> 8);
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar2) {
- SendText(Connection,Sender,sVar2);
- local_30 = Connection->NextToSend;
- }
- }
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_30 + 0x4000) {
- x_local._0_1_ = (uchar)Mode;
- Connection->OutData[iVar4 % 0x4000] = (uchar)x_local;
- iVar4 = iVar4 + 1;
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < local_30 + 0x3fff) {
- uVar5 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = (uchar)x;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 2;
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((uint)x >> 8);
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < local_30 + 0x3fff) {
- uVar5 = iVar4 + 1;
- Connection->OutData[iVar4 % 0x4000] = (uchar)y;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- iVar4 = iVar4 + 2;
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((uint)y >> 8);
- Connection->NextToWrite = iVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar4 < local_30 + 0x4000) {
- Text_local._0_1_ = (uchar)z;
- Connection->OutData[iVar4 % 0x4000] = (uchar)Text_local;
- Connection->NextToWrite = iVar4 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if (Text == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- sVar2 = strlen(Text);
- iVar4 = Connection->NextToWrite;
- if (iVar4 < local_30 + 0x3fff) {
- Connection->OutData[iVar4 % 0x4000] = (uchar)(sVar2 & 0xffff);
- uVar5 = iVar4 + 1;
- uVar3 = iVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)((sVar2 & 0xffff) >> 8);
- Connection->NextToWrite = iVar4 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar2) {
- SendText(Connection,Text,sVar2);
- }
- }
- FinishSendData(Connection);
- return;
- }
- return;
- }
- Connection = (TConnection *)s_SendTalk__K___Text_ist_NULL__08109e27;
- }
- error((char *)Connection);
- return;
-}
-
-
-
-// WARNING: Removing unreachable block (ram,0x080d5313)
-// WARNING: Variable defined which should be unmapped: pl
-
-void SendChannels(TConnection *Connection)
-
-{
- int iVar1;
- int iVar2;
- ulong uVar3;
- uint uVar4;
- bool bVar5;
- size_t sVar6;
- uint uVar7;
- int i;
- int iVar8;
- uchar uVar9;
- uchar uVar10;
- int Count;
- uint uVar11;
- uint uVar12;
- int i_1;
- uint uVar13;
- ulong uStack_50;
- size_t sStack_44;
- undefined1 auStack_40 [12];
- uint local_34;
- char *local_28;
- undefined1 *local_24;
- bool_0_ *Available;
- int local_1c;
- int Channels;
- TPlayer *pTStack_14;
- bool OwnChannel;
- TPlayer *pl;
-
- Available = &stack0xffffffb4;
- uStack_50 = 0x80d5017;
- bVar5 = BeginSendData(Connection);
- if (bVar5) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = 0xab;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- uStack_50 = 0x80d504d;
- pTStack_14 = TConnection::GetPlayer(Connection);
- if (pTStack_14 != (TPlayer *)0x0) {
- uVar9 = '\0';
- iVar8 = 0;
- uStack_50 = 0x80d506a;
- Channels._3_1_ = MayOpenChannel((pTStack_14->super_TCreature).ID);
- uStack_50 = 0x80d5072;
- local_1c = GetNumberOfChannels();
- iVar1 = -(local_1c + 0xfU & 0xfffffff0);
- local_24 = auStack_40 + iVar1;
- uVar10 = '\0';
- if (0 < local_1c) {
- do {
- uVar3 = (pTStack_14->super_TCreature).ID;
- *(int *)(&stack0xffffffb4 + iVar1) = iVar8;
- *(ulong *)(&stack0xffffffb8 + iVar1) = uVar3;
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d53bb;
- bVar5 = ChannelAvailable(*(int *)(&stack0xffffffb4 + iVar1),
- *(ulong *)(&stack0xffffffb8 + iVar1));
- uVar9 = uVar10;
- if (bVar5) {
- uVar9 = uVar10 + '\x01';
- }
- local_24[iVar8] = bVar5;
- iVar8 = iVar8 + 1;
- uVar10 = uVar9;
- } while (iVar8 < local_1c);
- }
- if (Channels._3_1_ != '\0') {
- uVar9 = uVar9 + '\x01';
- }
- iVar8 = Connection->NextToSend;
- iVar2 = Connection->NextToWrite;
- if (iVar2 < iVar8 + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = uVar9;
- Connection->NextToWrite = iVar2 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if (Channels._3_1_ != '\0') {
- iVar2 = Connection->NextToWrite;
- if (iVar2 < iVar8 + 0x3fff) {
- uVar11 = iVar2 + 1;
- uVar13 = iVar2 + 0x4000;
- if (-1 < (int)uVar11) {
- uVar13 = uVar11;
- }
- Connection->OutData[iVar2 % 0x4000] = 0xff;
- *(undefined1 *)((int)Connection + (uVar11 - (uVar13 & 0xffffc000)) + 0x806) =
- 0xff;
- Connection->NextToWrite = iVar2 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- *(char **)(&stack0xffffffb4 + iVar1) = "Private Chat Channel";
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d50f8;
- sVar6 = strlen(*(char **)(&stack0xffffffb4 + iVar1));
- iVar8 = Connection->NextToWrite;
- if (iVar8 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar8 % 0x4000] = (uchar)(sVar6 & 0xffff);
- uVar11 = iVar8 + 1;
- uVar13 = iVar8 + 0x4000;
- if (-1 < (int)uVar11) {
- uVar13 = uVar11;
- }
- *(char *)((int)Connection + (uVar11 - (uVar13 & 0xffffc000)) + 0x806) =
- (char)((sVar6 & 0xffff) >> 8);
- Connection->NextToWrite = iVar8 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar6) {
- *(size_t *)((int)&sStack_44 + iVar1) = sVar6;
- *(char **)(&stack0xffffffb8 + iVar1) = "Private Chat Channel";
- *(TConnection **)(&stack0xffffffb4 + iVar1) = Connection;
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d513b;
- SendText(*(TConnection **)(&stack0xffffffb4 + iVar1),
- *(char **)(&stack0xffffffb8 + iVar1),*(int *)((int)&sStack_44 + iVar1))
- ;
- }
- }
- if (0 < local_1c) {
- uVar13 = 0;
- do {
- if (local_24[uVar13] != '\0') {
- iVar8 = Connection->NextToWrite;
- if (iVar8 < Connection->NextToSend + 0x3fff) {
- uVar7 = iVar8 + 1;
- Connection->OutData[iVar8 % 0x4000] = (uchar)(uVar13 & 0xffff);
- uVar11 = iVar8 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar11 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar11 & 0xffffc000)) + 0x806) =
- (char)((uVar13 & 0xffff) >> 8);
- Connection->NextToWrite = iVar8 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- uVar3 = (pTStack_14->super_TCreature).ID;
- *(uint *)(&stack0xffffffb4 + iVar1) = uVar13;
- *(ulong *)(&stack0xffffffb8 + iVar1) = uVar3;
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d5198;
- local_28 = GetChannelName(*(int *)(&stack0xffffffb4 + iVar1),
- *(ulong *)(&stack0xffffffb8 + iVar1));
- if (local_28 == (char *)0x0) {
- *(char **)(&stack0xffffffb4 + iVar1) = "SendString: String ist NULL.\n";
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d5270;
- error(*(char **)(&stack0xffffffb4 + iVar1));
- }
- else {
- *(char **)(&stack0xffffffb4 + iVar1) = local_28;
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d51ae;
- sVar6 = strlen(*(char **)(&stack0xffffffb4 + iVar1));
- uVar11 = sVar6 & 0xffff;
- local_34 = uVar11;
- iVar8 = Connection->NextToWrite;
- if (iVar8 < Connection->NextToSend + 0x3fff) {
- local_34._0_1_ = (uchar)uVar11;
- Connection->OutData[iVar8 % 0x4000] = (uchar)local_34;
- uVar12 = iVar8 + 1;
- uVar7 = iVar8 + 0x4000;
- if (-1 < (int)uVar12) {
- uVar7 = uVar12;
- }
- local_34 = uVar11 >> 8;
- uVar4 = local_34;
- local_34._0_1_ = (uchar)(uVar11 >> 8);
- *(uchar *)((int)Connection + (uVar12 - (uVar7 & 0xffffc000)) + 0x806
- ) = (uchar)local_34;
- Connection->NextToWrite = iVar8 + 2;
- local_34 = uVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)sVar6) {
- *(size_t *)((int)&sStack_44 + iVar1) = sVar6;
- *(char **)(&stack0xffffffb8 + iVar1) = local_28;
- *(TConnection **)(&stack0xffffffb4 + iVar1) = Connection;
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d51ef;
- SendText(*(TConnection **)(&stack0xffffffb4 + iVar1),
- *(char **)(&stack0xffffffb8 + iVar1),
- *(int *)((int)&sStack_44 + iVar1));
- }
- }
- }
- uVar13 = uVar13 + 1;
- } while ((int)uVar13 < local_1c);
- }
- *(TConnection **)(&stack0xffffffb4 + iVar1) = Connection;
- *(undefined4 *)((int)&uStack_50 + iVar1) = 0x80d5204;
- FinishSendData(*(TConnection **)(&stack0xffffffb4 + iVar1));
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: pl
-
-void SendOpenChannel(TConnection *Connection,int Channel)
-
-{
- bool bVar1;
- TPlayer *pTVar2;
- int iVar3;
- char *__s;
- size_t Length;
- uint uVar4;
- uint uVar5;
- TPlayer *pl;
-
- bVar1 = BeginSendData(Connection);
- if (bVar1) {
- if (Channel == 3) {
- error("SendOpenChannel: Kanal ist GM-Request-Queue.\n");
- return;
- }
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0xac;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar2 = TConnection::GetPlayer(Connection);
- if (pTVar2 != (TPlayer *)0x0) {
- if ((-1 < Channel) && (iVar3 = GetNumberOfChannels(), Channel < iVar3)) {
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)(Channel & 0xffffU);
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Channel & 0xffffU) >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- __s = GetChannelName(Channel,(pTVar2->super_TCreature).ID);
- if (__s == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- Length = strlen(__s);
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,__s,Length);
- }
- }
- FinishSendData(Connection);
- return;
- }
- error(&DAT_081098a0);
- return;
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Name_local
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void SendPrivateChannel(TConnection *Connection,char *Name)
-
-{
- int iVar1;
- int iVar2;
- bool bVar3;
- size_t Length;
- uint uVar4;
- uint uVar5;
- char *Name_local;
-
- bVar3 = BeginSendData(Connection);
- if (!bVar3) {
- return;
- }
- iVar1 = Connection->NextToSend;
- iVar2 = Connection->NextToWrite;
- if (iVar2 < iVar1 + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = 0xad;
- Connection->NextToWrite = iVar2 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if (Name != (char *)0x0) {
- Length = strlen(Name);
- iVar2 = Connection->NextToWrite;
- if (iVar2 < iVar1 + 0x3fff) {
- Connection->OutData[iVar2 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar2 + 1;
- uVar4 = iVar2 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar2 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,Name,Length);
- }
- FinishSendData(Connection);
- return;
- }
- error("SendPrivateChannel: Name ist NULL.\n");
- return;
-}
-
-
-
-void SendOpenRequestQueue(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- uint uVar4;
- uint uVar5;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0xae;
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x3fff) {
- uVar5 = iVar3 + 1;
- Connection->OutData[iVar3 % 0x4000] = '\x03';
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(undefined1 *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) = 0;
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Name_local
-
-void __regparm2 SendDeleteRequest(TConnection *Connection,char *Name)
-
-{
- int iVar1;
- int iVar2;
- bool bVar3;
- size_t Length;
- uint uVar4;
- uint uVar5;
- TConnection *in_stack_00000004;
- char *in_stack_00000008;
- char *Name_local;
-
- bVar3 = BeginSendData(in_stack_00000004);
- if (!bVar3) {
- return;
- }
- iVar1 = in_stack_00000004->NextToSend;
- iVar2 = in_stack_00000004->NextToWrite;
- if (iVar2 < iVar1 + 0x4000) {
- in_stack_00000004->OutData[iVar2 % 0x4000] = 0xaf;
- in_stack_00000004->NextToWrite = iVar2 + 1;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- if (in_stack_00000008 != (char *)0x0) {
- Length = strlen(in_stack_00000008);
- iVar2 = in_stack_00000004->NextToWrite;
- if (iVar2 < iVar1 + 0x3fff) {
- in_stack_00000004->OutData[iVar2 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar2 + 1;
- uVar4 = iVar2 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)in_stack_00000004 + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- in_stack_00000004->NextToWrite = iVar2 + 2;
- }
- else {
- in_stack_00000004->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(in_stack_00000004,in_stack_00000008,Length);
- }
- FinishSendData(in_stack_00000004);
- return;
- }
- error("SendDeleteRequest: Name ist NULL.\n");
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Name_local
-// WARNING: Unknown calling convention -- yet parameter storage is locked
-
-void SendFinishRequest(TConnection *Connection,char *Name)
-
-{
- int iVar1;
- int iVar2;
- bool bVar3;
- size_t Length;
- uint uVar4;
- uint uVar5;
- char *Name_local;
-
- bVar3 = BeginSendData(Connection);
- if (!bVar3) {
- return;
- }
- iVar1 = Connection->NextToSend;
- iVar2 = Connection->NextToWrite;
- if (iVar2 < iVar1 + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = 0xb0;
- Connection->NextToWrite = iVar2 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- if (Name != (char *)0x0) {
- Length = strlen(Name);
- iVar2 = Connection->NextToWrite;
- if (iVar2 < iVar1 + 0x3fff) {
- Connection->OutData[iVar2 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar2 + 1;
- uVar4 = iVar2 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar2 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,Name,Length);
- }
- FinishSendData(Connection);
- return;
- }
- error("SendFinishRequest: Name ist NULL.\n");
- return;
-}
-
-
-
-void SendCloseRequest(TConnection *Connection)
-
-{
- int iVar1;
- bool bVar2;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToWrite;
- if (iVar1 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar1 % 0x4000] = 0xb1;
- Connection->NextToWrite = iVar1 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: pl
-
-void SendOpenOwnChannel(TConnection *Connection,int Channel)
-
-{
- bool bVar1;
- TPlayer *pTVar2;
- int iVar3;
- char *__s;
- size_t Length;
- uint uVar4;
- uint uVar5;
- TPlayer *pl;
-
- bVar1 = BeginSendData(Connection);
- if (bVar1) {
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0xb2;
- Connection->NextToWrite = iVar3 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar2 = TConnection::GetPlayer(Connection);
- if (pTVar2 != (TPlayer *)0x0) {
- if ((-1 < Channel) && (iVar3 = GetNumberOfChannels(), Channel < iVar3)) {
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)(Channel & 0xffffU);
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Channel & 0xffffU) >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- __s = GetChannelName(Channel,(pTVar2->super_TCreature).ID);
- if (__s == (char *)0x0) {
- error("SendString: String ist NULL.\n");
- }
- else {
- Length = strlen(__s);
- iVar3 = Connection->NextToWrite;
- if (iVar3 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar3 % 0x4000] = (uchar)(Length & 0xffff);
- uVar5 = iVar3 + 1;
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Length & 0xffff) >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- if (0 < (int)Length) {
- SendText(Connection,__s,Length);
- }
- }
- FinishSendData(Connection);
- return;
- }
- error(&DAT_081099e0);
- return;
- }
- }
- return;
-}
-
-
-
-void SendCloseChannel(TConnection *Connection,int Channel)
-
-{
- int iVar1;
- bool bVar2;
- int iVar3;
- uint uVar4;
- uint uVar5;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- iVar3 = Connection->NextToWrite;
- if (iVar3 < iVar1 + 0x4000) {
- Connection->OutData[iVar3 % 0x4000] = 0xb3;
- iVar3 = iVar3 + 1;
- Connection->NextToWrite = iVar3;
- }
- else {
- Connection->Overflow = true;
- }
- if (iVar3 < iVar1 + 0x3fff) {
- uVar5 = iVar3 + 1;
- Connection->OutData[iVar3 % 0x4000] = (uchar)(Channel & 0xffffU);
- uVar4 = iVar3 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar4 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar4 & 0xffffc000)) + 0x806) =
- (char)((Channel & 0xffffU) >> 8);
- Connection->NextToWrite = iVar3 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-void SendOutfit(TConnection *Connection)
-
-{
- undefined2 uVar1;
- int iVar2;
- bool bVar3;
- TPlayer *pTVar4;
- uint uVar5;
- short sVar6;
- TPlayer *pl;
- uint uVar7;
-
- bVar3 = BeginSendData(Connection);
- if (bVar3) {
- iVar2 = Connection->NextToWrite;
- if (iVar2 < Connection->NextToSend + 0x4000) {
- Connection->OutData[iVar2 % 0x4000] = 200;
- Connection->NextToWrite = iVar2 + 1;
- }
- else {
- Connection->Overflow = true;
- }
- pTVar4 = TConnection::GetPlayer(Connection);
- if (pTVar4 != (TPlayer *)0x0) {
- uVar1 = (undefined2)(pTVar4->super_TCreature).OrgOutfit.OutfitID;
- iVar2 = Connection->NextToWrite;
- if (iVar2 < Connection->NextToSend + 0x3fff) {
- Connection->OutData[iVar2 % 0x4000] = (uchar)uVar1;
- uVar7 = iVar2 + 1;
- uVar5 = iVar2 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)uVar1 >> 8);
- Connection->NextToWrite = iVar2 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- SendText(Connection,(char *)(pTVar4->super_TCreature).OrgOutfit.field_1.Colors,4);
- if ((pTVar4->super_TCreature).Sex == 1) {
- iVar2 = Connection->NextToWrite;
- if (iVar2 < Connection->NextToSend + 0x3fff) {
- uVar7 = iVar2 + 1;
- Connection->OutData[iVar2 % 0x4000] = 0x80;
- uVar5 = iVar2 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(undefined1 *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) = 0;
- Connection->NextToWrite = iVar2 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- bVar3 = CheckRight((pTVar4->super_TCreature).ID,PREMIUM_ACCOUNT);
- sVar6 = (ushort)bVar3 * 3 + 0x83;
- }
- else {
- iVar2 = Connection->NextToWrite;
- if (iVar2 < Connection->NextToSend + 0x3fff) {
- uVar7 = iVar2 + 1;
- Connection->OutData[iVar2 % 0x4000] = 0x88;
- uVar5 = iVar2 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(undefined1 *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) = 0;
- Connection->NextToWrite = iVar2 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- bVar3 = CheckRight((pTVar4->super_TCreature).ID,PREMIUM_ACCOUNT);
- sVar6 = (ushort)bVar3 * 3 + 0x8b;
- }
- iVar2 = Connection->NextToWrite;
- if (iVar2 < Connection->NextToSend + 0x3fff) {
- uVar7 = iVar2 + 1;
- Connection->OutData[iVar2 % 0x4000] = (uchar)sVar6;
- uVar5 = iVar2 + 0x4000;
- if (-1 < (int)uVar7) {
- uVar5 = uVar7;
- }
- *(char *)((int)Connection + (uVar7 - (uVar5 & 0xffffc000)) + 0x806) =
- (char)((ushort)sVar6 >> 8);
- Connection->NextToWrite = iVar2 + 2;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Name_local
-
-void __regparm2 SendBuddyData(TConnection *Connection,ulong CharacterID,char *Name,bool Online)
-
-{
- bool bVar1;
- size_t Length;
- uint uVar2;
- int iVar3;
- uint uVar4;
- undefined3 in_stack_00000009;
- char *in_stack_0000000c;
- char in_stack_00000010;
- int local_20;
- bool Online_local;
- char *Name_local;
-
- bVar1 = BeginSendData((TConnection *)Name);
- if (bVar1) {
- local_20 = *(int *)(Name + 0x4808);
- iVar3 = *(int *)(Name + 0x4810);
- if (iVar3 < local_20 + 0x4000) {
- Name[iVar3 % 0x4000 + 0x806] = -0x2e;
- iVar3 = iVar3 + 1;
- *(int *)(Name + 0x4810) = iVar3;
- }
- else {
- Name[0x4814] = '\x01';
- }
- if (iVar3 < local_20 + 0x3ffd) {
- uVar4 = iVar3 + 1;
- Name[iVar3 % 0x4000 + 0x806] = Online;
- uVar2 = iVar3 + 0x4000;
- if (-1 < (int)uVar4) {
- uVar2 = uVar4;
- }
- Name[(uVar4 - (uVar2 & 0xffffc000)) + 0x806] = (char)in_stack_00000009;
- uVar4 = iVar3 + 2;
- uVar2 = iVar3 + 0x4001;
- if (-1 < (int)uVar4) {
- uVar2 = uVar4;
- }
- Name[(uVar4 - (uVar2 & 0xffffc000)) + 0x806] = (char)((uint3)in_stack_00000009 >> 8);
- uVar4 = iVar3 + 3;
- uVar2 = iVar3 + 0x4002;
- if (-1 < (int)uVar4) {
- uVar2 = uVar4;
- }
- Name[(uVar4 - (uVar2 & 0xffffc000)) + 0x806] = (char)((uint3)in_stack_00000009 >> 0x10);
- *(int *)(Name + 0x4810) = iVar3 + 4;
- }
- else {
- Name[0x4814] = '\x01';
- }
- if (in_stack_0000000c != (char *)0x0) {
- Length = strlen(in_stack_0000000c);
- iVar3 = *(int *)(Name + 0x4810);
- if (iVar3 < local_20 + 0x3fff) {
- Name[iVar3 % 0x4000 + 0x806] = (char)(Length & 0xffff);
- uVar4 = iVar3 + 1;
- uVar2 = iVar3 + 0x4000;
- if (-1 < (int)uVar4) {
- uVar2 = uVar4;
- }
- Name[(uVar4 - (uVar2 & 0xffffc000)) + 0x806] = (char)((Length & 0xffff) >> 8);
- *(int *)(Name + 0x4810) = iVar3 + 2;
- }
- else {
- Name[0x4814] = '\x01';
- }
- if (0 < (int)Length) {
- SendText((TConnection *)Name,in_stack_0000000c,Length);
- local_20 = *(int *)(Name + 0x4808);
- }
- iVar3 = *(int *)(Name + 0x4810);
- if (iVar3 < local_20 + 0x4000) {
- Name[iVar3 % 0x4000 + 0x806] = in_stack_00000010 != '\0';
- *(int *)(Name + 0x4810) = iVar3 + 1;
- }
- else {
- Name[0x4814] = '\x01';
- }
- FinishSendData((TConnection *)Name);
- return;
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Online_local
-
-void SendBuddyStatus(TConnection *Connection,ulong CharacterID,bool Online)
-
-{
- int iVar1;
- bool bVar2;
- uint uVar3;
- uint uVar4;
- uint uVar5;
- bool Online_local;
-
- bVar2 = BeginSendData(Connection);
- if (bVar2) {
- iVar1 = Connection->NextToSend;
- uVar4 = Connection->NextToWrite;
- if ((int)uVar4 < iVar1 + 0x4000) {
- uVar3 = uVar4 + 0x3fff;
- if (-1 < (int)uVar4) {
- uVar3 = uVar4;
- }
- *(char *)((int)Connection + (uVar4 - (uVar3 & 0xffffc000)) + 0x806) = !Online + -0x2d;
- uVar4 = uVar4 + 1;
- Connection->NextToWrite = uVar4;
- }
- else {
- Connection->Overflow = true;
- }
- if ((int)uVar4 < iVar1 + 0x3ffd) {
- uVar5 = uVar4 + 1;
- Connection->OutData[(int)uVar4 % 0x4000] = (uchar)CharacterID;
- uVar3 = uVar4 + 0x4000;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(CharacterID >> 8);
- uVar5 = uVar4 + 2;
- uVar3 = uVar4 + 0x4001;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(CharacterID >> 0x10);
- uVar5 = uVar4 + 3;
- uVar3 = uVar4 + 0x4002;
- if (-1 < (int)uVar5) {
- uVar3 = uVar5;
- }
- *(char *)((int)Connection + (uVar5 - (uVar3 & 0xffffc000)) + 0x806) =
- (char)(CharacterID >> 0x18);
- Connection->NextToWrite = uVar4 + 4;
- }
- else {
- Connection->Overflow = true;
- }
- FinishSendData(Connection);
- return;
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Message
-
-void BroadcastMessage(int Mode,char *Text,...)
-
-{
- TConnection *Connection_00;
- TConnection *Connection;
- char local_40c [4];
- char Message [1024];
-
- vsnprintf(local_40c,0x400,Text,&stack0x0000000c);
- Connection_00 = GetFirstConnection();
- while (Connection_00 != (TConnection *)0x0) {
- if (Connection_00->State - CONNECTION_LOGIN < 4) {
- SendMessage(Connection_00,Mode,local_40c);
- }
- Connection_00 = GetNextConnection();
- }
- return;
-}
-
-
-
-void DeleteGamemasterRequest(char *Name)
-
-{
- bool bVar1;
- TPlayer *pl;
- TConnection *this;
- TPlayer *pTVar2;
- undefined3 extraout_var;
- char *Name_00;
- TConnection *Connection;
-
- if (Name != (char *)0x0) {
- this = GetFirstConnection();
- while (this != (TConnection *)0x0) {
- if ((this->State - CONNECTION_LOGIN < 4) &&
- (pTVar2 = TConnection::GetPlayer(this), pTVar2 != (TPlayer *)0x0)) {
- bVar1 = ChannelSubscribed(3,(pTVar2->super_TCreature).ID);
- if (bVar1) {
- SendDeleteRequest((TConnection *)CONCAT31(extraout_var,bVar1),Name_00);
- }
- }
- this = GetNextConnection();
- }
- return;
- }
- error("DeleteGamemasterRequest: Name ist NULL.\n");
- return;
-}
-
-
-
// WARNING: Unknown calling convention -- yet parameter storage is locked
void _GLOBAL__I__Z13BeginSendDataP11TConnection(void)
diff --git a/src/connections.cc b/src/connections.cc index 2604a9e..fe26fea 100644 --- a/src/connections.cc +++ b/src/connections.cc @@ -11,79 +11,8 @@ static Semaphore ConnectionMutex(1); static int ConnectionIterator; -static TConnection *FirstSendingConnection; static TConnection Connections[MAX_CONNECTIONS]; -enum ClientCommand: int { - CL_CMD_LOGIN = 10, - CL_CMD_LOGIN_TREATED = 11, - CL_CMD_LOGOUT = 20, - CL_CMD_PING = 30, - CL_CMD_GO = 100, - CL_CMD_GO_NORTH = 101, - CL_CMD_GO_EAST = 102, - CL_CMD_GO_SOUTH = 103, - CL_CMD_GO_WEST = 104, - CL_CMD_GO_STOP = 105, - CL_CMD_GO_NORTHEAST = 106, - CL_CMD_GO_SOUTHEAST = 107, - CL_CMD_GO_SOUTHWEST = 108, - CL_CMD_GO_NORTHWEST = 109, - CL_CMD_ROTATE_NORTH = 111, - CL_CMD_ROTATE_EAST = 112, - CL_CMD_ROTATE_SOUTH = 113, - CL_CMD_ROTATE_WEST = 114, - CL_CMD_MOVE_OBJECT = 120, - CL_CMD_TRADE_OBJECT = 125, - CL_CMD_INSPECT_TRADE = 126, - CL_CMD_ACCEPT_TRADE = 127, - CL_CMD_REJECT_TRADE = 128, - CL_CMD_USE_OBJECT = 130, - CL_CMD_USE_TWO_OBJECTS = 131, - CL_CMD_USE_ON_CREATURE = 132, - CL_CMD_TURN_OBJECT = 133, - CL_CMD_CLOSE_CONTAINER = 135, - CL_CMD_UP_CONTAINER = 136, - CL_CMD_EDIT_TEXT = 137, - CL_CMD_EDIT_LIST = 138, - CL_CMD_LOOK_AT_POINT = 140, - CL_CMD_TALK = 150, - CL_CMD_GET_CHANNELS = 151, - CL_CMD_JOIN_CHANNEL = 152, - CL_CMD_LEAVE_CHANNEL = 153, - CL_CMD_PRIVATE_CHANNEL = 154, - CL_CMD_PROCESS_REQUEST = 155, - CL_CMD_REMOVE_REQUEST = 156, - CL_CMD_CANCEL_REQUEST = 157, - CL_CMD_SET_TACTICS = 160, - CL_CMD_ATTACK = 161, - CL_CMD_FOLLOW = 162, - CL_CMD_INVITE_TO_PARTY = 163, - CL_CMD_JOIN_PARTY = 164, - CL_CMD_REVOKE_INVITATION = 165, - CL_CMD_PASS_LEADERSHIP = 166, - CL_CMD_LEAVE_PARTY = 167, - CL_CMD_OPEN_CHANNEL = 170, - CL_CMD_INVITE_TO_CHANNEL = 171, - CL_CMD_EXCLUDE_FROM_CHANNEL = 172, - CL_CMD_CANCEL = 190, - CL_CMD_REFRESH_FIELD = 201, - CL_CMD_REFRESH_CONTAINER = 202, - CL_CMD_GET_OUTFIT = 210, - CL_CMD_SET_OUTFIT = 211, - CL_CMD_ADD_BUDDY = 220, - CL_CMD_REMOVE_BUDDY = 221, - CL_CMD_BUG_REPORT = 230, - CL_CMD_RULE_VIOLATION = 231, - CL_CMD_ERROR_FILE_ENTRY = 232, -}; - -enum ServerCommand: int { - SV_CMD_LOGIN_ERROR = 20, - SV_CMD_LOGIN_PREMIUM = 21, - SV_CMD_LOGIN_WAITINGLIST = 22, -}; - // TConnection // ============================================================================= TConnection::TConnection(void){ @@ -563,13 +492,16 @@ void ProcessConnections(void){ } void InitConnections(void){ + InitSending(); + InitReceiving(); + ConnectionIterator = 0; - FirstSendingConnection = NULL; for(int i = 0; i < MAX_CONNECTIONS; i += 1){ Connections[i].State = CONNECTION_FREE; } } void ExitConnections(void){ - // no-op + ExitSending(); + ExitReceiving(); } diff --git a/src/connections.hh b/src/connections.hh index 921a604..17cf7df 100644 --- a/src/connections.hh +++ b/src/connections.hh @@ -4,10 +4,139 @@ #include "common.hh" #include "crypto.hh" #include "enums.hh" +#include "map.hh" struct TConnection; struct TPlayer; +enum ClientCommand: int { + CL_CMD_LOGIN = 10, + CL_CMD_LOGIN_TREATED = 11, + CL_CMD_LOGOUT = 20, + CL_CMD_PING = 30, + CL_CMD_GO = 100, + CL_CMD_GO_NORTH = 101, + CL_CMD_GO_EAST = 102, + CL_CMD_GO_SOUTH = 103, + CL_CMD_GO_WEST = 104, + CL_CMD_GO_STOP = 105, + CL_CMD_GO_NORTHEAST = 106, + CL_CMD_GO_SOUTHEAST = 107, + CL_CMD_GO_SOUTHWEST = 108, + CL_CMD_GO_NORTHWEST = 109, + CL_CMD_ROTATE_NORTH = 111, + CL_CMD_ROTATE_EAST = 112, + CL_CMD_ROTATE_SOUTH = 113, + CL_CMD_ROTATE_WEST = 114, + CL_CMD_MOVE_OBJECT = 120, + CL_CMD_TRADE_OBJECT = 125, + CL_CMD_INSPECT_TRADE = 126, + CL_CMD_ACCEPT_TRADE = 127, + CL_CMD_REJECT_TRADE = 128, + CL_CMD_USE_OBJECT = 130, + CL_CMD_USE_TWO_OBJECTS = 131, + CL_CMD_USE_ON_CREATURE = 132, + CL_CMD_TURN_OBJECT = 133, + CL_CMD_CLOSE_CONTAINER = 135, + CL_CMD_UP_CONTAINER = 136, + CL_CMD_EDIT_TEXT = 137, + CL_CMD_EDIT_LIST = 138, + CL_CMD_LOOK_AT_POINT = 140, + CL_CMD_TALK = 150, + CL_CMD_GET_CHANNELS = 151, + CL_CMD_JOIN_CHANNEL = 152, + CL_CMD_LEAVE_CHANNEL = 153, + CL_CMD_PRIVATE_CHANNEL = 154, + CL_CMD_PROCESS_REQUEST = 155, + CL_CMD_REMOVE_REQUEST = 156, + CL_CMD_CANCEL_REQUEST = 157, + CL_CMD_SET_TACTICS = 160, + CL_CMD_ATTACK = 161, + CL_CMD_FOLLOW = 162, + CL_CMD_INVITE_TO_PARTY = 163, + CL_CMD_JOIN_PARTY = 164, + CL_CMD_REVOKE_INVITATION = 165, + CL_CMD_PASS_LEADERSHIP = 166, + CL_CMD_LEAVE_PARTY = 167, + CL_CMD_OPEN_CHANNEL = 170, + CL_CMD_INVITE_TO_CHANNEL = 171, + CL_CMD_EXCLUDE_FROM_CHANNEL = 172, + CL_CMD_CANCEL = 190, + CL_CMD_REFRESH_FIELD = 201, + CL_CMD_REFRESH_CONTAINER = 202, + CL_CMD_GET_OUTFIT = 210, + CL_CMD_SET_OUTFIT = 211, + CL_CMD_ADD_BUDDY = 220, + CL_CMD_REMOVE_BUDDY = 221, + CL_CMD_BUG_REPORT = 230, + CL_CMD_RULE_VIOLATION = 231, + CL_CMD_ERROR_FILE_ENTRY = 232, +}; + +enum ServerCommand: int { + SV_CMD_INIT_GAME = 10, + SV_CMD_RIGHTS = 11, + SV_CMD_LOGIN_ERROR = 20, + SV_CMD_LOGIN_PREMIUM = 21, + SV_CMD_LOGIN_WAITINGLIST = 22, + SV_CMD_PING = 30, + SV_CMD_FULLSCREEN = 100, + SV_CMD_ROW_NORTH = 101, + SV_CMD_ROW_EAST = 102, + SV_CMD_ROW_SOUTH = 103, + SV_CMD_ROW_WEST = 104, + SV_CMD_FIELD_DATA = 105, + SV_CMD_ADD_FIELD = 106, + SV_CMD_CHANGE_FIELD = 107, + SV_CMD_DELETE_FIELD = 108, + SV_CMD_MOVE_CREATURE = 109, + SV_CMD_CONTAINER = 110, + SV_CMD_CLOSE_CONTAINER = 111, + SV_CMD_CREATE_IN_CONTAINER = 112, + SV_CMD_CHANGE_IN_CONTAINER = 113, + SV_CMD_DELETE_IN_CONTAINER = 114, + SV_CMD_SET_INVENTORY = 120, + SV_CMD_DELETE_INVENTORY = 121, + SV_CMD_TRADE_OFFER_OWN = 125, + SV_CMD_TRADE_OFFER_PARTNER = 126, + SV_CMD_CLOSE_TRADE = 127, + SV_CMD_AMBIENTE = 130, + SV_CMD_GRAPHICAL_EFFECT = 131, + SV_CMD_TEXTUAL_EFFECT = 132, + SV_CMD_MISSILE_EFFECT = 133, + SV_CMD_MARK_CREATURE = 134, + SV_CMD_CREATURE_HEALTH = 140, + SV_CMD_CREATURE_LIGHT = 141, + SV_CMD_CREATURE_OUTFIT = 142, + SV_CMD_CREATURE_SPEED = 143, + SV_CMD_CREATURE_SKULL = 144, + SV_CMD_CREATURE_PARTY = 145, + SV_CMD_EDIT_TEXT = 150, + SV_CMD_EDIT_LIST = 151, + SV_CMD_PLAYER_DATA = 160, + SV_CMD_PLAYER_SKILLS = 161, + SV_CMD_PLAYER_STATE = 162, + SV_CMD_CLEAR_TARGET = 163, + SV_CMD_TALK = 170, + SV_CMD_CHANNELS = 171, + SV_CMD_OPEN_CHANNEL = 172, + SV_CMD_PRIVATE_CHANNEL = 173, + SV_CMD_OPEN_REQUEST = 174, + SV_CMD_DELETE_REQUEST = 175, + SV_CMD_FINISH_REQUEST = 176, + SV_CMD_CLOSE_REQUEST = 177, + SV_CMD_OPEN_OWN_CHANNEL = 178, + SV_CMD_CLOSE_CHANNEL = 179, + SV_CMD_MESSAGE = 180, + SV_CMD_SNAPBACK = 181, + SV_CMD_FLOOR_UP = 190, + SV_CMD_FLOOR_DOWN = 191, + SV_CMD_OUTFIT = 200, + SV_CMD_BUDDY_DATA = 210, + SV_CMD_BUDDY_ONLINE = 211, + SV_CMD_BUDDY_OFFLINE = 212, +}; + // TODO(fusion): The maximum number of connections should probably be kept in // sync with the maximum number of communication threads, or maybe it is the // same constant. @@ -93,6 +222,7 @@ struct TConnection { TKnownCreature KnownCreatureTable[150]; }; +// connections.cc TConnection *AssignFreeConnection(void); TConnection *GetFirstConnection(void); TConnection *GetNextConnection(void); @@ -100,4 +230,82 @@ void ProcessConnections(void); void InitConnections(void); void ExitConnections(void); +// sending.cc +void SendAll(void); +bool BeginSendData(TConnection *Connection); +void FinishSendData(TConnection *Connection); +void SkipFlush(TConnection *Connection); +void SendMapObject(TConnection *Connection, Object Obj); +void SendMapPoint(TConnection *Connection, int x, int y, int z); +void SendResult(TConnection *Connection, RESULT r); +void SendRefresh(TConnection *Connection); +void SendInitGame(TConnection *Connection, uint32 CreatureID); +void SendRights(TConnection *Connection); +void SendPing(TConnection *Connection); +void SendFullScreen(TConnection *Connection); +void SendRow(TConnection *Connection, int Direction); +void SendFloors(TConnection *Connection, bool Up); +void SendFieldData(TConnection *Connection, int x, int y, int z); +void SendAddField(TConnection *Connection, int x, int y, int z, Object Obj); +void SendChangeField(TConnection *Connection, int x, int y, int z, Object Obj); +void SendDeleteField(TConnection *Connection, int x, int y, int z, Object Obj); +void SendMoveCreature(TConnection *Connection, + uint32 CreatureID, int DestX, int DestY, int DestZ); +void SendContainer(TConnection *Connection, int ContainerNr); +void SendCloseContainer(TConnection *Connection, int ContainerNr); +void SendCreateInContainer(TConnection *Connection, int ContainerNr, Object Obj); +void SendChangeInContainer(TConnection *Connection, int ContainerNr, Object Obj); +void SendDeleteInContainer(TConnection *Connection, int ContainerNr, Object Obj); +void SendBodyInventory(TConnection *Connection, uint32 CreatureID); +void SendSetInventory(TConnection *Connection, int Position, Object Obj); +void SendDeleteInventory(TConnection *Connection, int Position); +void SendTradeOffer(TConnection *Connection, const char *Name, bool OwnOffer, Object Obj); +void SendCloseTrade(TConnection *Connection); +void SendAmbiente(TConnection *Connection); +void SendGraphicalEffect(TConnection *Connection, int x, int y, int z, int Type); +void SendTextualEffect(TConnection *Connection, int x, int y, int z, int Color, const char *Text); +void SendMissileEffect(TConnection *Connection, int OrigX, int OrigY, int OrigZ, + int DestX, int DestY, int DestZ, int Type); +void SendMarkCreature(TConnection *Connection, uint32 CreatureID, int Color); +void SendCreatureHealth(TConnection *Connection, uint32 CreatureID); +void SendCreatureLight(TConnection *Connection, uint32 CreatureID); +void SendCreatureOutfit(TConnection *Connection, uint32 CreatureID); +void SendCreatureSpeed(TConnection *Connection, uint32 CreatureID); +void SendCreatureSkull(TConnection *Connection, uint32 CreatureID); +void SendCreatureParty(TConnection *Connection, uint32 CreatureID); +void SendEditText(TConnection *Connection, Object Obj); +void SendEditList(TConnection *Connection, uint8 Type, uint32 ID, const char *Text); +void SendPlayerData(TConnection *Connection); +void SendPlayerSkills(TConnection *Connection); +void SendPlayerState(TConnection *Connection, uint8 State); +void SendClearTarget(TConnection *Connection); +void SendTalk(TConnection *Connection, uint32 StatementID, + const char *Sender, int Mode, const char *Text, int Data); +void SendTalk(TConnection *Connection, uint32 StatementID, + const char *Sender, int Mode, int Channel, const char *Text); +void SendTalk(TConnection *Connection, uint32 StatementID, + const char *Sender, int Mode, int x, int y, int z, const char *Text); +void SendChannels(TConnection *Connection); +void SendOpenChannel(TConnection *Connection, int Channel); +void SendPrivateChannel(TConnection *Connection, const char *Name); +void SendOpenRequest(TConnection *Connection); +void SendDeleteRequest(TConnection *Connection, const char *Name); +void SendFinishRequest(TConnection *Connection, const char *Name); +void SendCloseRequest(TConnection *Connection); +void SendOpenOwnChannel(TConnection *Connection, int Channel); +void SendCloseChannel(TConnection *Connection, int Channel); +void SendMessage(TConnection *Connection, int Mode, const char *Text, ...) ATTR_PRINTF(3, 4); +void SendSnapback(TConnection *Connection); +void SendOutfit(TConnection *Connection); +void SendBuddyData(TConnection *Connection, uint32 CharacterID, const char *Name, bool Online); +void SendBuddyStatus(TConnection *Connection, uint32 CharacterID, bool Online); +void BroadcastMessage(int Mode, const char *Text, ...) ATTR_PRINTF(2, 3); +void DeleteGamemasterRequest(const char *Name); +void InitSending(void); +void ExitSending(void); + +// receiving.cc +void InitReceiving(void); +void ExitReceiving(void); + #endif // TIBIA_CONNECTIONS_HH_ diff --git a/src/operate.hh b/src/operate.hh index 3cb5075..85cbf9f 100644 --- a/src/operate.hh +++ b/src/operate.hh @@ -22,8 +22,6 @@ enum : int { OBJECT_MOVED = 3, }; -#if 0 -// TODO(fusion): Use these? enum : int { CHANNEL_GUILD = 0, CHANNEL_GAMEMASTER = 1, @@ -38,7 +36,6 @@ enum : int { CHANNEL_FIRST = 0, CHANNEL_LAST = 0xFFFF, }; -#endif struct TChannel { TChannel(void); diff --git a/src/sending.cc b/src/sending.cc new file mode 100644 index 0000000..52c3e28 --- /dev/null +++ b/src/sending.cc @@ -0,0 +1,1751 @@ +#include "connections.hh" +#include "config.hh" +#include "cr.hh" +#include "info.hh" +#include "map.hh" + +#include "stubs.hh" + +#include <signal.h> + +#define MAX_OBJECTS_PER_POINT 10 +#define MAX_OBJECTS_PER_CONTAINER 36 + +static int Skip = -1; +static TConnection *FirstSendingConnection; + +void SendAll(void){ + TConnection *Connection = FirstSendingConnection; + FirstSendingConnection = NULL; + while(Connection != NULL){ + if(Connection->WillingToSend){ + Connection->WillingToSend = false; + if(Connection->Live() && Connection->NextToCommit > Connection->NextToSend){ + kill(Connection->GetPID(), SIGUSR2); + } + }else{ + error("SendAll: Verbindung ist nicht sendewillig.\n"); + } + Connection = Connection->NextSendingConnection; + } +} + +bool BeginSendData(TConnection *Connection){ + bool Result = false; + if(Connection != NULL && Connection->Live() && Connection->State != CONNECTION_LOGIN){ + int OutDataCommitted = (Connection->NextToCommit - Connection->NextToSend); + int OutDataCapacity = (int)sizeof(Connection->OutData); + if(OutDataCommitted < OutDataCapacity){ + Connection->NextToWrite = Connection->NextToCommit; + Connection->Overflow = false; + Result = true; + }else{ + print(2, "BeginSendData: Puffer von Verbindung %d ist voll.\n", Connection->GetSocket()); + } + } + return Result; +} + +void FinishSendData(TConnection *Connection){ + if(Connection == NULL){ + error("FinishSendData: Verbindung ist NULL.\n"); + return; + } + + if(!Connection->Live()){ + error("FinishSendData: Verbindung ist nicht online.\n"); + return; + } + + if(Connection->Overflow){ + print(2, "FinishSendData: Puffer ist voll. Paket wird nicht versandt.\n"); + return; + } + + Connection->NextToCommit = Connection->NextToWrite; + if(!Connection->WillingToSend){ + Connection->WillingToSend = true; + Connection->NextSendingConnection = FirstSendingConnection; + FirstSendingConnection = Connection; + } +} + +static void SendByte(TConnection *Connection, uint8 Value){ + int OutDataWritten = (Connection->NextToWrite - Connection->NextToSend); + int OutDataCapacity = (int)sizeof(Connection->OutData); + if((OutDataWritten + 1) > OutDataCapacity){ + Connection->Overflow = true; + return; + } + + Connection->OutData[Connection->NextToWrite % OutDataCapacity] = Value; + Connection->NextToWrite += 1; +} + +static void SendWord(TConnection *Connection, uint16 Value){ + int OutDataWritten = (Connection->NextToWrite - Connection->NextToSend); + int OutDataCapacity = (int)sizeof(Connection->OutData); + if((OutDataWritten + 2) > OutDataCapacity){ + Connection->Overflow = true; + return; + } + + Connection->OutData[(Connection->NextToWrite + 0) % OutDataCapacity] = (uint8)(Value >> 0); + Connection->OutData[(Connection->NextToWrite + 1) % OutDataCapacity] = (uint8)(Value >> 8); + Connection->NextToWrite += 2; +} + +static void SendQuad(TConnection *Connection, uint32 Value){ + int OutDataWritten = (Connection->NextToWrite - Connection->NextToSend); + int OutDataCapacity = (int)sizeof(Connection->OutData); + if((OutDataWritten + 4) > OutDataCapacity){ + Connection->Overflow = true; + return; + } + + Connection->OutData[(Connection->NextToWrite + 0) % OutDataCapacity] = (uint8)(Value >> 0); + Connection->OutData[(Connection->NextToWrite + 1) % OutDataCapacity] = (uint8)(Value >> 8); + Connection->OutData[(Connection->NextToWrite + 2) % OutDataCapacity] = (uint8)(Value >> 16); + Connection->OutData[(Connection->NextToWrite + 3) % OutDataCapacity] = (uint8)(Value >> 24); + Connection->NextToWrite += 4; +} + +// NOTE(fusion): This was called `SendText` but since most these sending helpers +// were inlined, I just renamed it to something that made more sense. +static void SendBytes(TConnection *Connection, const uint8 *Buffer, int Count){ + if(Buffer == NULL){ + error("SendText: Text ist NULL.\n"); + return; + } + + if(Count <= 0){ + error("SendText: ungültige Textlänge %d.\n", Count); + return; + } + + int OutDataWritten = (Connection->NextToWrite - Connection->NextToSend); + int OutDataCapacity = (int)sizeof(Connection->OutData); + if((OutDataWritten + Count) > OutDataCapacity){ + Connection->Overflow = true; + return; + } + + int BufferStart = Connection->NextToWrite % OutDataCapacity; + int BufferEnd = BufferStart + Count; + if(BufferEnd < OutDataCapacity){ + memcpy(&Connection->OutData[BufferStart], Buffer, Count); + }else{ + int Size1 = OutDataCapacity - BufferStart; + int Size2 = BufferEnd - OutDataCapacity; + memcpy(&Connection->OutData[BufferStart], &Buffer[0], Size1); + memcpy(&Connection->OutData[0], &Buffer[Size1], Size2); + } + + Connection->NextToWrite += Count; +} + +static void SendString(TConnection *Connection, const char *String){ + if(String == NULL){ + error("SendString: String ist NULL.\n"); + return; + } + + int StringLength = (int)strlen(String); + SendWord(Connection, (uint16)StringLength); + if(StringLength > 0){ + SendBytes(Connection, (const uint8*)String, StringLength); + } +} + +static void SendOutfit(TConnection *Connection, TOutfit Outfit){ + SendWord(Connection, (uint16)Outfit.OutfitID); + if(Outfit.OutfitID == 0){ + SendWord(Connection, Outfit.ObjectType); + }else{ + SendBytes(Connection, Outfit.Colors, sizeof(Outfit.Colors)); + } +} + +static void SendItem(TConnection *Connection, Object Obj){ + ObjectType ObjType = Obj.getObjectType(); + SendWord(Connection, (uint16)ObjType.getDisguise().TypeID); + + if(ObjType.getFlag(LIQUIDCONTAINER)){ + int LiquidType = (int)Obj.getAttribute(CONTAINERLIQUIDTYPE); + SendByte(Connection, GetLiquidColor(LiquidType)); + } + + if(ObjType.getFlag(LIQUIDPOOL)){ + int LiquidType = (int)Obj.getAttribute(POOLLIQUIDTYPE); + SendByte(Connection, GetLiquidColor(LiquidType)); + } + + if(ObjType.getFlag(CUMULATIVE)){ + SendByte(Connection, (uint8)Obj.getAttribute(AMOUNT)); + } +} + +void SkipFlush(TConnection *Connection){ + while(Skip >= 0){ + int Count = std::min<int>(Skip, UINT8_MAX); + SendByte(Connection, (uint8)Count); + SendByte(Connection, UINT8_MAX); + Skip -= (Count + 1); + } +} + +void SendMapObject(TConnection *Connection, Object Obj){ + if(!Obj.exists()){ + error("SendMapObject: Übergebenes Objekt existiert nicht.\n"); + return; + } + + if(!Obj.getObjectType().isCreatureContainer()){ + SendItem(Connection, Obj); + return; + } + + // TODO(fusion): This might also be contained in its own `SendCreature` function? + TCreature *Creature = GetCreature(Obj); + if(Creature == NULL){ + error("SendMapObject: Kreatur hat kein Kreatur-Objekt\n"); + return; + } + + KNOWNCREATURESTATE KnownState = Connection->KnownCreature(Creature->ID, true); + if(KnownState == KNOWNCREATURE_UPTODATE){ + SendWord(Connection, 99); + SendQuad(Connection, Creature->ID); + SendByte(Connection, (uint8)Creature->Direction); + }else if(KnownState == KNOWNCREATURE_OUTDATED + || KnownState == KNOWNCREATURE_FREE){ + if(KnownState == KNOWNCREATURE_FREE){ + SendWord(Connection, 97); + SendQuad(Connection, Connection->NewKnownCreature(Creature->ID)); + SendQuad(Connection, Creature->ID); + if(Creature->Type == MONSTER){ + // TODO(fusion): Apparently the monster name contains its + // article. I'm not sure it is a good idea and this probably + // lead to other bugs such as a monster having a two part name + // with no article. + const char *Name = findFirst(Creature->Name, ' '); + if(Name != NULL){ + Name += 1; + }else{ + Name = Creature->Name; + } + SendString(Connection, Name); + }else{ + SendString(Connection, Creature->Name); + } + }else{ + SendWord(Connection, 98); + SendQuad(Connection, Creature->ID); + } + + int Brightness, Color; + GetCreatureLight(Creature->ID, &Brightness, &Color); + + int PlayerkillingMark = SKULL_NONE; + int PartyMark = PARTY_SHIELD_NONE; + if(Creature->Type == PLAYER){ + TPlayer *Player = (TPlayer*)Creature; + TPlayer *Observer = Connection->GetPlayer(); + PlayerkillingMark = Player->GetPlayerkillingMark(Observer); + PartyMark = Player->GetPartyMark(Observer); + } + + SendByte(Connection, (uint8)Creature->GetHealth()); + SendByte(Connection, (uint8)Creature->Direction); + SendOutfit(Connection, Creature->Outfit); + SendByte(Connection, (uint8)Brightness); + SendByte(Connection, (uint8)Color); + SendWord(Connection, (uint16)Creature->GetSpeed()); + SendByte(Connection, (uint8)PlayerkillingMark); + SendByte(Connection, (uint8)PartyMark); + } +} + +void SendMapPoint(TConnection *Connection, int x, int y, int z){ + Object Obj = GetFirstObject(x, y, z); + if(Obj != NONE){ + SkipFlush(Connection); + int ObjCount = 0; + while(Obj != NONE && ObjCount < MAX_OBJECTS_PER_POINT){ + SendMapObject(Connection, Obj); + Obj = Obj.getNextObject(); + } + } + Skip += 1; +} + +void SendResult(TConnection *Connection, RESULT r){ + if(Connection == NULL){ + return; + } + + const char *Message = NULL; + switch(r) { + case NOERROR: error("SendResult: NOERROR\n"); break; + case NOTACCESSIBLE: Message = "Sorry, not possible."; break; + case NOTMOVABLE: Message = "You cannot move this object."; break; + case NOTTAKABLE: Message = "You cannot take this object."; break; + case NOROOM: Message = "There is not enough room."; break; + case OUTOFRANGE: Message = "Destination is out of range."; break; + case OUTOFHOME: error("SendResult: OUTOFHOME\n"); break; + case CANNOTTHROW: Message = "You cannot throw there."; break; + case TOOHEAVY: Message = "This object is too heavy."; break; + case CROSSREFERENCE: Message = "This is impossible."; break; + case CONTAINERFULL: Message = "You cannot put more objects in this container."; break; + case WRONGPOSITION: Message = "Put this object in your hand."; break; + case WRONGPOSITION2: Message = "Put this object in both hands."; break; + case WRONGCLOTHES: Message = "You cannot dress this object there."; break; + case HANDSNOTFREE: Message = "Both hands have to be free."; break; + case HANDBLOCKED: Message = "Drop the double-handed object first."; break; + case ONEWEAPONONLY: Message = "You may only use one weapon."; break; + case NOMATCH: error("SendResult: NOMATCH\n"); break; + case NOTCUMULABLE: error("SendResult: NOTCUMULABLE\n"); break; + case TOOMANYPARTS: error("SendResult: TOOMANYPARTS\n"); break; + case EMPTYCONTAINER: error("SendResult: EMPTYCONTAINER\n"); break; + case SPLITOBJECT: error("SendResult: SPLITOBJECT\n"); break; + case NOKEYMATCH: Message = "The key does not match."; break; + case UPSTAIRS: Message = "First go upstairs."; break; + case DOWNSTAIRS: Message = "First go downstairs."; break; + case CREATURENOTEXISTING: Message = "A creature with this name does not exist."; break; + case PLAYERNOTEXISTING: Message = "A player with this name does not exist."; break; + case PLAYERNOTONLINE: Message = "A player with this name is not online."; break; + case NAMEAMBIGUOUS: Message = "Playername is ambiguous."; break; + case NOTUSABLE: Message = "You cannot use this object."; break; + case FEDUP: Message = "You are full."; break; + case SPELLUNKNOWN: Message = "You must learn this spell first."; break; + case LOWMAGICLEVEL: Message = "Your magic level is too low."; break; + case MAGICITEM: Message = "A magic item is necessary to cast this spell."; break; + case NOTENOUGHMANA: Message = "You do not have enough mana."; break; + case NOSKILL: error("SendResult: NOSKILL\n"); break; + case TARGETLOST: Message = "Target lost."; break; + case NOCREATURE: Message = "You can only use this rune on creatures."; break; + case TOOLONG: error("SendResult: TOOLONG\n"); break; + case ATTACKNOTALLOWED: Message = "You may not attack this person."; break; + case NOWAY: Message = "There is no way."; break; + case LOGINERROR: Message = "An error occured while logging in."; break; + case PROTECTIONZONE: Message = "This action is not permitted in a protection zone."; break; + case ENTERPROTECTIONZONE: Message = "Characters who attacked other players may not enter a protection zone."; break; + case EXHAUSTED: Message = "You are exhausted."; break; + case NOTINVITED: Message = "You are not invited."; break; + case NOPREMIUMACCOUNT: Message = "You need a premium account."; break; + case MOVENOTPOSSIBLE: Message = "Sorry, not possible."; break; + case ALREADYTRADING: Message = "You are already trading. Finish this trade first."; break; + case PARTNERTRADING: Message = "This person is already trading."; break; + case TOOMANYOBJECTS: Message = "You can only trade up to 100 objects at one time."; break; + case TOOMANYSLAVES: Message = "You cannot control more creatures."; break; + case NOTTURNABLE: Message = "You cannot turn this object."; break; + case SECUREMODE: Message = "Turn secure mode off if you really want to attack unmarked players."; break; + case NOTENOUGHSOULPOINTS: Message = "You do not have enough soulpoints."; break; + case LOWLEVEL: Message = "Your level is too low."; break; + default: break; + } + + if(Message != NULL){ + if(r == ENTERPROTECTIONZONE || r == NOTINVITED || r == MOVENOTPOSSIBLE){ + SendSnapback(Connection); + } + SendMessage(Connection, TALK_FAILURE_MESSAGE, "Sorry, not possible."); + } +} + +void SendRefresh(TConnection *Connection){ + SendFullScreen(Connection); + SendAmbiente(Connection); + SendPlayerData(Connection); + SendPlayerSkills(Connection); +} + +void SendInitGame(TConnection *Connection, uint32 CreatureID){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_INIT_GAME); + SendQuad(Connection, CreatureID); + SendWord(Connection, (uint16)Beat); + SendByte(Connection, CheckRight(CreatureID, SEND_BUGREPORTS) ? 1 : 0); + FinishSendData(Connection); +} + +void SendRights(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_RIGHTS); + + // NOTE(fusion): See `CheckBanishmentRight`. + bool Count = 0; + for(int Reason = 0; Reason <= 31; Reason += 1){ + uint8 Actions = 0; + if(CheckRight(Connection->CharacterID, (RIGHT)(Reason + 18))){ + for(int Action = 0; Action <= 6; Action += 1){ + if(CheckBanishmentRight(Connection->CharacterID, Reason, Action)){ + Actions |= (1 << Action); + } + } + + if(Actions != 0){ + if(CheckRight(Connection->CharacterID, IP_BANISHMENT)){ + Actions |= 0x80; + } + Count += 1; + } + } + + SendByte(Connection, Actions); + } + + if(Count > 0){ + FinishSendData(Connection); + } +} + +void SendPing(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_PING); + FinishSendData(Connection); +} + +void SendFullScreen(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + int PlayerX, PlayerY, PlayerZ; + Connection->GetPosition(&PlayerX, &PlayerY, &PlayerZ); + int MinX = PlayerX - Connection->TerminalOffsetX; + int MinY = PlayerY - Connection->TerminalOffsetY; + int MaxX = MinX + Connection->TerminalWidth - 1; + int MaxY = MinY + Connection->TerminalHeight - 1; + + // NOTE(fusion): `EndZ` is exclusive. + int StartZ, EndZ, StepZ; + if(PlayerZ <= 7){ + StepZ = -1; + StartZ = 7; + EndZ = 0 + StepZ; + }else{ + StepZ = 1; + StartZ = PlayerZ - 2; + EndZ = std::min<int>(PlayerZ + 2, 15) + StepZ; + } + + SendByte(Connection, SV_CMD_FULLSCREEN); + SendWord(Connection, (uint16)PlayerX); + SendWord(Connection, (uint16)PlayerY); + SendByte(Connection, (uint8)PlayerZ); + + Skip = -1; + for(int PointZ = StartZ; PointZ != EndZ; EndZ += StepZ){ + int ZOffset = (PlayerZ - PointZ); + for(int PointX = MinX; PointX <= MaxX; PointX += 1) + for(int PointY = MinY; PointY <= MaxY; PointY += 1){ + SendMapPoint(Connection, PointX + ZOffset, PointY + ZOffset, PlayerZ); + } + } + SkipFlush(Connection); + + FinishSendData(Connection); +} + +void SendRow(TConnection *Connection, int Direction){ + if(!BeginSendData(Connection)){ + return; + } + + int PlayerX, PlayerY, PlayerZ; + Connection->GetPosition(&PlayerX, &PlayerY, &PlayerZ); + int MinX = PlayerX - Connection->TerminalOffsetX; + int MinY = PlayerY - Connection->TerminalOffsetY; + int MaxX = MinX + Connection->TerminalWidth - 1; + int MaxY = MinY + Connection->TerminalHeight - 1; + + // NOTE(fusion): `EndZ` is exclusive. + int StartZ, EndZ, StepZ; + if(PlayerZ <= 7){ + StepZ = -1; + StartZ = 7; + EndZ = 0 + StepZ; + }else{ + StepZ = 1; + StartZ = PlayerZ - 2; + EndZ = std::min<int>(PlayerZ + 2, 15) + StepZ; + } + + if(Direction == DIRECTION_NORTH){ + SendByte(Connection, SV_CMD_ROW_NORTH); + MaxY = MinY; + }else if(Direction == DIRECTION_EAST){ + SendByte(Connection, SV_CMD_ROW_EAST); + MinX = MaxX; + }else if(Direction == DIRECTION_SOUTH){ + SendByte(Connection, SV_CMD_ROW_SOUTH); + MinY = MaxY; + }else if(Direction == DIRECTION_WEST){ + SendByte(Connection, SV_CMD_ROW_WEST); + MaxX = MinX; + }else{ + error("SendRow: Ungültige Richtungsangabe %d.\n", Direction); + return; + } + + Skip = -1; + for(int PointZ = StartZ; PointZ != EndZ; EndZ += StepZ){ + int ZOffset = (PlayerZ - PointZ); + for(int PointX = MinX; PointX <= MaxX; PointX += 1) + for(int PointY = MinY; PointY <= MaxY; PointY += 1){ + SendMapPoint(Connection, PointX + ZOffset, PointY + ZOffset, PlayerZ); + } + } + SkipFlush(Connection); + + FinishSendData(Connection); +} + +void SendFloors(TConnection *Connection, bool Up){ + if(!BeginSendData(Connection)){ + return; + } + + int PlayerX, PlayerY, PlayerZ; + Connection->GetPosition(&PlayerX, &PlayerY, &PlayerZ); + + // NOTE(fusion): `EndZ` is exclusive. + int StartZ = -1; + int EndZ = -1; + int StepZ = 0; + if(Up){ + SendByte(Connection, SV_CMD_FLOOR_UP); + if(PlayerZ == 7){ + // NOTE(fusion): Going to surface (8 -> 7). The client currently has + // floors [10, 6] so we only need to send floors [5, 0]. + StepZ = -1; + StartZ = 5; + EndZ = 0 + StepZ; + }else if(PlayerZ > 7){ + // NOTE(fusion): Going up but still underground. Send next floor up. + StepZ = -1; + StartZ = PlayerZ - 2; + EndZ = StartZ + StepZ; + } + }else{ + SendByte(Connection, SV_CMD_FLOOR_DOWN); + if(PlayerZ == 8){ + // NOTE(fusion): Going underground (7 -> 8). The client currently has + // floors [7, 0] so we only need to send floors [10, 8]. + StepZ = 1; + StartZ = 8; + EndZ = 10 + StepZ; + }else if(PlayerZ > 8 && (PlayerZ + 2) <= 15){ + // NOTE(fusion): Going down while underground. Send next floor down + // if it exists. + StepZ = 1; + StartZ = PlayerZ + 2; + EndZ = StartZ + StepZ; + } + } + + if(StartZ != EndZ){ + int MinX = PlayerX - Connection->TerminalOffsetX; + int MinY = PlayerY - Connection->TerminalOffsetY; + int MaxX = MinX + Connection->TerminalWidth - 1; + int MaxY = MinY + Connection->TerminalHeight - 1; + + Skip = -1; + for(int PointZ = StartZ; PointZ != EndZ; EndZ += StepZ){ + int ZOffset = (PlayerZ - PointZ); + for(int PointX = MinX; PointX <= MaxX; PointX += 1) + for(int PointY = MinY; PointY <= MaxY; PointY += 1){ + SendMapPoint(Connection, PointX + ZOffset, PointY + ZOffset, PlayerZ); + } + } + SkipFlush(Connection); + } + + FinishSendData(Connection); +} + +void SendFieldData(TConnection *Connection, int x, int y, int z){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_FIELD_DATA); + SendWord(Connection, (uint16)x); + SendWord(Connection, (uint16)y); + SendByte(Connection, (uint8)z); + + Skip = -1; + SendMapPoint(Connection, x, y, z); + SkipFlush(Connection); + + FinishSendData(Connection); +} + +void SendAddField(TConnection *Connection, int x, int y, int z, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(!Obj.exists()){ + error("SendAddField: Übergebenes Objekt existiert nicht.\n"); + return; + } + + SendByte(Connection, SV_CMD_ADD_FIELD); + SendWord(Connection, (uint16)x); + SendWord(Connection, (uint16)y); + SendByte(Connection, (uint8)z); + SendMapObject(Connection, Obj); + FinishSendData(Connection); +} + +void SendChangeField(TConnection *Connection, int x, int y, int z, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(!Obj.exists()){ + error("SendChangeField: Übergebenes Objekt existiert nicht.\n"); + return; + } + + int ObjIndex = GetObjectRNum(Obj); + if(ObjIndex < MAX_OBJECTS_PER_POINT){ + SendByte(Connection, SV_CMD_CHANGE_FIELD); + SendWord(Connection, (uint16)x); + SendWord(Connection, (uint16)y); + SendByte(Connection, (uint8)z); + SendByte(Connection, (uint8)ObjIndex); + SendMapObject(Connection, Obj); + FinishSendData(Connection); + } +} + +void SendDeleteField(TConnection *Connection, int x, int y, int z, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(!Obj.exists()){ + error("SendDeleteField: Übergebenes Objekt existiert nicht.\n"); + return; + } + + int ObjIndex = GetObjectRNum(Obj); + if(ObjIndex < MAX_OBJECTS_PER_POINT){ + SendByte(Connection, SV_CMD_DELETE_FIELD); + SendWord(Connection, (uint16)x); + SendWord(Connection, (uint16)y); + SendByte(Connection, (uint8)z); + SendByte(Connection, (uint8)ObjIndex); + FinishSendData(Connection); + } +} + +void SendMoveCreature(TConnection *Connection, + uint32 CreatureID, int DestX, int DestY, int DestZ){ + if(Connection == NULL){ + return; + } + + TCreature *Creature = GetCreature(CreatureID); + if(Creature == NULL){ + error("SendMoveCreature: Kreatur existiert nicht.\n"); + return; + } + + int OrigX = Creature->posx; + int OrigY = Creature->posy; + int OrigZ = Creature->posz; + int OrigIndex = GetObjectRNum(Creature->CrObject); + bool IsVisible = Connection->IsVisible(DestX, DestY, DestZ); + bool WasVisible = OrigIndex < MAX_OBJECTS_PER_POINT + && Connection->IsVisible(OrigX, OrigY, OrigZ); + if(IsVisible && WasVisible){ + if(BeginSendData(Connection)){ + SendByte(Connection, SV_CMD_MOVE_CREATURE); + SendWord(Connection, (uint16)OrigX); + SendWord(Connection, (uint16)OrigY); + SendByte(Connection, (uint8)OrigZ); + SendByte(Connection, (uint8)OrigIndex); + SendWord(Connection, (uint16)DestX); + SendWord(Connection, (uint16)DestY); + SendByte(Connection, (uint8)DestZ); + FinishSendData(Connection); + } + }else if(IsVisible){ + SendAddField(Connection, DestX, DestY, DestZ, Creature->CrObject); + }else if(WasVisible){ + SendDeleteField(Connection, OrigX, OrigY, OrigZ, Creature->CrObject); + } +} + +void SendContainer(TConnection *Connection, int ContainerNr){ + if(!BeginSendData(Connection)){ + return; + } + + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + error("SendContainer: Zu dieser Verbindung gehört kein Spieler.\n"); + return; + } + + Object Con = Player->GetOpenContainer(ContainerNr); + if(!Con.exists()){ + error("SendContainer: Container %d existiert nicht.\n", ContainerNr); + return; + } + + ObjectType ConType = Con.getObjectType(); + bool HasUpContainer = (Con.getContainer() != NONE + && !Con.getContainer().getObjectType().isBodyContainer()); + + int ConObjects = CountObjectsInContainer(Con); + if(ConObjects > MAX_OBJECTS_PER_CONTAINER){ + ConObjects = MAX_OBJECTS_PER_CONTAINER; + } + + SendByte(Connection, SV_CMD_CONTAINER); + SendByte(Connection, (uint8)ContainerNr); + SendWord(Connection, (uint16)ConType.getDisguise().TypeID); + SendString(Connection, ConType.getName(-1)); + SendByte(Connection, (uint8)ConType.getAttribute(CAPACITY)); + SendByte(Connection, HasUpContainer ? 1 : 0); + SendByte(Connection, (uint8)ConObjects); + + Object Obj = GetFirstContainerObject(Con); + while(Obj != NONE && ConObjects > 0){ + SendItem(Connection, Obj); + Obj = Obj.getNextObject(); + ConObjects -= 1; + } + + FinishSendData(Connection); +} + +void SendCloseContainer(TConnection *Connection, int ContainerNr){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_CLOSE_CONTAINER); + SendByte(Connection, (uint8)ContainerNr); + FinishSendData(Connection); +} + +void SendCreateInContainer(TConnection *Connection, int ContainerNr, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_CREATE_IN_CONTAINER); + SendByte(Connection, (uint8)ContainerNr); + SendItem(Connection, Obj); + FinishSendData(Connection); +} + +void SendChangeInContainer(TConnection *Connection, int ContainerNr, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(!Obj.exists()){ + error("SendChangeInContainer: Übergebenes Objekt existiert nicht.\n"); + return; + } + + int ObjIndex = GetObjectRNum(Obj); + if(ObjIndex < MAX_OBJECTS_PER_CONTAINER){ + SendByte(Connection, SV_CMD_CHANGE_IN_CONTAINER); + SendByte(Connection, (uint8)ContainerNr); + SendByte(Connection, (uint8)ObjIndex); + SendItem(Connection, Obj); + FinishSendData(Connection); + } +} + +void SendDeleteInContainer(TConnection *Connection, int ContainerNr, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(!Obj.exists()){ + error("SendDeleteInContainer: Übergebenes Objekt existiert nicht.\n"); + return; + } + + int ObjIndex = GetObjectRNum(Obj); + if(ObjIndex < MAX_OBJECTS_PER_CONTAINER){ + SendByte(Connection, SV_CMD_DELETE_IN_CONTAINER); + SendByte(Connection, (uint8)ContainerNr); + SendByte(Connection, (uint8)ObjIndex); + FinishSendData(Connection); + } +} + +void SendBodyInventory(TConnection *Connection, uint32 CreatureID){ + for(int Position = INVENTORY_FIRST; + Position <= INVENTORY_LAST; + Position += 1){ + Object Obj = GetBodyObject(CreatureID, Position); + if(Obj != NONE){ + SendSetInventory(Connection, Position, Obj); + } + } +} + +void SendSetInventory(TConnection *Connection, int Position, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(!Obj.exists()){ + error("SendSetInventory: Objekt existiert nicht.\n"); + return; + } + + SendByte(Connection, SV_CMD_SET_INVENTORY); + SendByte(Connection, (uint8)Position); + SendItem(Connection, Obj); + FinishSendData(Connection); +} + +void SendDeleteInventory(TConnection *Connection, int Position){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_DELETE_INVENTORY); + SendByte(Connection, (uint8)Position); + FinishSendData(Connection); +} + +static void SendTradeObjects(TConnection *Connection, Object Obj){ + if(!Obj.exists()){ + return; + } + + SendItem(Connection, Obj); + if(Obj.getObjectType().getFlag(CONTAINER)){ + Object Help = GetFirstContainerObject(Obj); + while(Help != NONE){ + SendTradeObjects(Connection, Help); + Help = Help.getNextObject(); + } + } +} + +void SendTradeOffer(TConnection *Connection, const char *Name, bool OwnOffer, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(Name == NULL){ + error("SendTradeOffer: Name ist NULL.\n"); + return; + } + + if(!Obj.exists()){ + error("SendTradeOffer: Objekt existiert nicht.\n"); + return; + } + + int ObjCount = CountObjects(Obj); + if(ObjCount > UINT8_MAX){ + error("SendTradeOffer: Too many objects.\n"); + return; + } + + if(OwnOffer){ + SendByte(Connection, SV_CMD_TRADE_OFFER_OWN); + }else{ + SendByte(Connection, SV_CMD_TRADE_OFFER_PARTNER); + } + + SendString(Connection, Name); + SendByte(Connection, (uint8)ObjCount); + SendTradeObjects(Connection, Obj); + FinishSendData(Connection); +} + +void SendCloseTrade(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_CLOSE_TRADE); + FinishSendData(Connection); +} + +void SendAmbiente(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + int Brightness, Color; + GetAmbiente(&Brightness, &Color); + + SendByte(Connection, SV_CMD_AMBIENTE); + SendByte(Connection, (uint8)Brightness); + SendByte(Connection, (uint8)Color); + FinishSendData(Connection); +} + +void SendGraphicalEffect(TConnection *Connection, int x, int y, int z, int Type){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_GRAPHICAL_EFFECT); + SendWord(Connection, (uint16)x); + SendWord(Connection, (uint16)y); + SendByte(Connection, (uint8)z); + SendByte(Connection, (uint8)Type); + FinishSendData(Connection); +} + +void SendTextualEffect(TConnection *Connection, int x, int y, int z, int Color, const char *Text){ + if(Text == NULL){ + error("SendTextualEffect: Text ist NULL.\n"); + return; + } + + if(Text[0] == 0){ + error("SendTextualEffect: Text ist leer.\n"); + return; + } + + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_TEXTUAL_EFFECT); + SendWord(Connection, (uint16)x); + SendWord(Connection, (uint16)y); + SendByte(Connection, (uint8)z); + SendByte(Connection, (uint8)Color); + SendString(Connection, Text); + FinishSendData(Connection); +} + +void SendMissileEffect(TConnection *Connection, int OrigX, int OrigY, int OrigZ, + int DestX, int DestY, int DestZ, int Type){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_MISSILE_EFFECT); + SendWord(Connection, (uint16)OrigX); + SendWord(Connection, (uint16)OrigY); + SendByte(Connection, (uint8)OrigZ); + SendWord(Connection, (uint16)DestX); + SendWord(Connection, (uint16)DestY); + SendByte(Connection, (uint8)DestZ); + SendByte(Connection, (uint8)Type); + FinishSendData(Connection); +} + +void SendMarkCreature(TConnection *Connection, uint32 CreatureID, int Color){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_MARK_CREATURE); + SendQuad(Connection, CreatureID); + SendByte(Connection, (uint8)Color); + FinishSendData(Connection); +} + +void SendCreatureHealth(TConnection *Connection, uint32 CreatureID){ + if(!BeginSendData(Connection)){ + return; + } + + TCreature *Creature = GetCreature(CreatureID); + if(Creature == NULL){ + error("SendCreatureHealth: Kreatur %u existiert nicht.\n", CreatureID); + return; + } + + SendByte(Connection, SV_CMD_CREATURE_HEALTH); + SendQuad(Connection, CreatureID); + SendByte(Connection, (uint8)Creature->GetHealth()); + FinishSendData(Connection); +} + +void SendCreatureLight(TConnection *Connection, uint32 CreatureID){ + if(!BeginSendData(Connection)){ + return; + } + + TCreature *Creature = GetCreature(CreatureID); + if(Creature == NULL){ + error("SendCreatureLight: Kreatur %u existiert nicht.\n", CreatureID); + return; + } + + int Brightness, Color; + GetCreatureLight(CreatureID, &Brightness, &Color); + + SendByte(Connection, SV_CMD_CREATURE_LIGHT); + SendQuad(Connection, CreatureID); + SendByte(Connection, (uint8)Brightness); + SendByte(Connection, (uint8)Color); + FinishSendData(Connection); +} + +void SendCreatureOutfit(TConnection *Connection, uint32 CreatureID){ + if(!BeginSendData(Connection)){ + return; + } + + TCreature *Creature = GetCreature(CreatureID); + if(Creature == NULL){ + error("SendCreatureOutfit: Kreatur %u existiert nicht.\n", CreatureID); + return; + } + + SendByte(Connection, SV_CMD_CREATURE_OUTFIT); + SendQuad(Connection, CreatureID); + SendOutfit(Connection, Creature->Outfit); + FinishSendData(Connection); +} + +void SendCreatureSpeed(TConnection *Connection, uint32 CreatureID){ + if(!BeginSendData(Connection)){ + return; + } + + TCreature *Creature = GetCreature(CreatureID); + if(Creature == NULL){ + error("SendCreatureSpeed: Kreatur %u existiert nicht.\n", CreatureID); + return; + } + + SendByte(Connection, SV_CMD_CREATURE_SPEED); + SendQuad(Connection, CreatureID); + SendWord(Connection, (uint16)Creature->GetSpeed()); + FinishSendData(Connection); +} + +void SendCreatureSkull(TConnection *Connection, uint32 CreatureID){ + if(!BeginSendData(Connection)){ + return; + } + + TPlayer *Player = GetPlayer(CreatureID); + if(Player == NULL){ + error("SendCreatureSkull: Kreatur %u existiert nicht.\n", CreatureID); + return; + } + + SendByte(Connection, SV_CMD_CREATURE_SKULL); + SendQuad(Connection, CreatureID); + SendByte(Connection, Player->GetPlayerkillingMark(Connection->GetPlayer())); + FinishSendData(Connection); +} + +void SendCreatureParty(TConnection *Connection, uint32 CreatureID){ + if(!BeginSendData(Connection)){ + return; + } + + TPlayer *Player = GetPlayer(CreatureID); + if(Player == NULL){ + error("SendCreatureParty: Kreatur %u existiert nicht.\n", CreatureID); + return; + } + + SendByte(Connection, SV_CMD_CREATURE_PARTY); + SendQuad(Connection, CreatureID); + SendByte(Connection, Player->GetPartyMark(Connection->GetPlayer())); + FinishSendData(Connection); +} + +void SendEditText(TConnection *Connection, Object Obj){ + if(!BeginSendData(Connection)){ + return; + } + + if(!Obj.exists()){ + error("SendEditText: Übergebenes Objekt existiert nicht.\n"); + return; + } + + ObjectType ObjType = Obj.getObjectType(); + int TypeID = ObjType.getDisguise().TypeID; + int MaxLength = 0; + const char *Text = NULL; + const char *Editor = NULL; + char SpellbookBuffer[4096] = {}; + if(ObjType.getFlag(WRITE) || ObjType.getFlag(WRITEONCE)){ + MaxLength = (ObjType.getFlag(WRITE) + ? ObjType.getAttribute(MAXLENGTH) + : ObjType.getAttribute(MAXLENGTHONCE)); + MaxLength -= 1; + Text = GetDynamicString(Obj.getAttribute(TEXTSTRING)); + Editor = GetDynamicString(Obj.getAttribute(EDITOR)); + }else if(ObjType.getFlag(INFORMATION) + && ObjType.getAttribute(INFORMATIONTYPE) == 4){ // INFORMATION_SPELLBOOK ? + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + error("SendEditText: Zu dieser Verbindung gehört kein Spieler.\n"); + return; + } + + GetSpellbook(Player->ID, SpellbookBuffer); + Text = SpellbookBuffer; + MaxLength = strlen(Text); + }else{ + Text = GetDynamicString(Obj.getAttribute(TEXTSTRING)); + Editor = GetDynamicString(Obj.getAttribute(EDITOR)); + if(Text != NULL){ + MaxLength = strlen(Text); + } + } + + SendByte(Connection, SV_CMD_EDIT_TEXT); + SendQuad(Connection, Obj.ObjectID); + SendWord(Connection, (uint16)TypeID); + SendWord(Connection, (uint16)MaxLength); + if(Text != NULL){ + SendString(Connection, Text); + SendString(Connection, (Editor != NULL ? Editor : "")); + }else{ + SendString(Connection, ""); + SendString(Connection, ""); + } + + FinishSendData(Connection); +} + +void SendEditList(TConnection *Connection, uint8 Type, uint32 ID, const char *Text){ + if(!BeginSendData(Connection)){ + return; + } + + if(Text == NULL){ + error("SendEditList: Text ist NULL.\n"); + return; + } + + if(strlen(Text) >= 4000){ + error("SendEditList: Text ist zu lang.\n"); + return; + } + + SendByte(Connection, SV_CMD_EDIT_LIST); + SendByte(Connection, Type); + SendQuad(Connection, ID); + SendString(Connection, Text); + FinishSendData(Connection); +} + +void SendPlayerData(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + error("SendStatus: Zu dieser Verbindung gehört kein Spieler.\n"); + return; + } + + // TODO(fusion): I don't even think skills can even be NULL. + int Level = 0; + int LevelPercent = 0; + int Experience = 0; + int MagicLevel = 0; + int MagicLevelPercent = 0; + int HitPoints = 0; + int MaxHitPoints = 0; + int ManaPoints = 0; + int MaxManaPoints = 0; + int Capacity = 0; + int SoulPoints = 0; + + if(Player->Skills[SKILL_LEVEL] != NULL){ + Level = Player->Skills[SKILL_LEVEL]->Get(); + LevelPercent = Player->Skills[SKILL_LEVEL]->GetProgress(); + Experience = Player->Skills[SKILL_LEVEL]->Exp; + } + + if(Player->Skills[SKILL_MAGIC_LEVEL] != NULL){ + MagicLevel = Player->Skills[SKILL_MAGIC_LEVEL]->Get(); + MagicLevelPercent = Player->Skills[SKILL_MAGIC_LEVEL]->GetProgress(); + } + + if(Player->Skills[SKILL_HITPOINTS] != NULL){ + HitPoints = Player->Skills[SKILL_HITPOINTS]->Get(); + MaxHitPoints = Player->Skills[SKILL_HITPOINTS]->Max; + } + + if(Player->Skills[SKILL_MANA] != NULL){ + ManaPoints = Player->Skills[SKILL_MANA]->Get(); + MaxManaPoints = Player->Skills[SKILL_MANA]->Max; + } + + if(Player->Skills[SKILL_CARRY_STRENGTH] != NULL + && !CheckRight(Player->ID, ZERO_CAPACITY)){ + int InventoryWeight = GetInventoryWeight(Player->ID); + int MaxWeight = Player->Skills[SKILL_CARRY_STRENGTH]->Get() * 100; + Capacity = (MaxWeight - InventoryWeight) / 100; + } + + if(Player->Skills[SKILL_SOUL] != NULL){ + SoulPoints = Player->Skills[SKILL_SOUL]->Get(); + } + + SendByte(Connection, SV_CMD_PLAYER_DATA); + SendWord(Connection, (uint16)HitPoints); + SendWord(Connection, (uint16)MaxHitPoints); + SendWord(Connection, (uint16)Capacity); + SendQuad(Connection, (uint32)Experience); + SendWord(Connection, (uint16)Level); + SendByte(Connection, (uint8)LevelPercent); + SendWord(Connection, (uint16)ManaPoints); + SendWord(Connection, (uint16)MaxManaPoints); + SendByte(Connection, (uint8)MagicLevel); + SendByte(Connection, (uint8)MagicLevelPercent); + SendByte(Connection, (uint8)SoulPoints); + FinishSendData(Connection); +} + +void SendPlayerSkills(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + error("SendPlayerSkills: Zu dieser Verbindung gehört kein Spieler.\n"); + return; + } + + // TODO(fusion): I don't even think skills can even be NULL. + int FistLevel = 0; + int FistPercent = 0; + int ClubLevel = 0; + int ClubPercent = 0; + int SwordLevel = 0; + int SwordPercent = 0; + int AxeLevel = 0; + int AxePercent = 0; + int DistanceLevel = 0; + int DistancePercent = 0; + int ShieldingLevel = 0; + int ShieldingPercent = 0; + int FishingLevel = 0; + int FishingPercent = 0; + + if(Player->Skills[SKILL_FIST] != NULL){ + FistLevel = Player->Skills[SKILL_FIST]->Get(); + FistPercent = Player->Skills[SKILL_FIST]->GetProgress(); + } + + if(Player->Skills[SKILL_CLUB] != NULL){ + ClubLevel = Player->Skills[SKILL_CLUB]->Get(); + ClubPercent = Player->Skills[SKILL_CLUB]->GetProgress(); + } + + if(Player->Skills[SKILL_SWORD] != NULL){ + SwordLevel = Player->Skills[SKILL_SWORD]->Get(); + SwordPercent = Player->Skills[SKILL_SWORD]->GetProgress(); + } + + if(Player->Skills[SKILL_AXE] != NULL){ + AxeLevel = Player->Skills[SKILL_AXE]->Get(); + AxePercent = Player->Skills[SKILL_AXE]->GetProgress(); + } + + if(Player->Skills[SKILL_DISTANCE] != NULL){ + DistanceLevel = Player->Skills[SKILL_DISTANCE]->Get(); + DistancePercent = Player->Skills[SKILL_DISTANCE]->GetProgress(); + } + + if(Player->Skills[SKILL_SHIELDING] != NULL){ + ShieldingLevel = Player->Skills[SKILL_SHIELDING]->Get(); + ShieldingPercent = Player->Skills[SKILL_SHIELDING]->GetProgress(); + } + + if(Player->Skills[SKILL_FISHING] != NULL){ + FishingLevel = Player->Skills[SKILL_FISHING]->Get(); + FishingPercent = Player->Skills[SKILL_FISHING]->GetProgress(); + } + + SendByte(Connection, SV_CMD_PLAYER_SKILLS); + SendByte(Connection, (uint8)FistLevel); + SendByte(Connection, (uint8)FistPercent); + SendByte(Connection, (uint8)ClubLevel); + SendByte(Connection, (uint8)ClubPercent); + SendByte(Connection, (uint8)SwordLevel); + SendByte(Connection, (uint8)SwordPercent); + SendByte(Connection, (uint8)AxeLevel); + SendByte(Connection, (uint8)AxePercent); + SendByte(Connection, (uint8)DistanceLevel); + SendByte(Connection, (uint8)DistancePercent); + SendByte(Connection, (uint8)ShieldingLevel); + SendByte(Connection, (uint8)ShieldingPercent); + SendByte(Connection, (uint8)FishingLevel); + SendByte(Connection, (uint8)FishingPercent); + FinishSendData(Connection); +} + +void SendPlayerState(TConnection *Connection, uint8 State){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_PLAYER_STATE); + SendByte(Connection, State); + FinishSendData(Connection); +} + +void SendClearTarget(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_CLEAR_TARGET); + FinishSendData(Connection); +} + +void SendTalk(TConnection *Connection, uint32 StatementID, + const char *Sender, int Mode, const char *Text, int Data){ + if(Mode != TALK_PRIVATE_MESSAGE + && Mode != TALK_GAMEMASTER_REQUEST + && Mode != TALK_GAMEMASTER_ANSWER + && Mode != TALK_PLAYER_ANSWER + && Mode != TALK_GAMEMASTER_BROADCAST + && Mode != TALK_GAMEMASTER_MESSAGE){ + error("SendTalk (-): Ungültiger Modus %d.\n", Mode); + return; + } + + if(Sender == NULL){ + error("SendTalk (-): Sender ist NULL.\n"); + return; + } + + if(Text == NULL){ + error("SendTalk (-): Text ist NULL.\n"); + return; + } + + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_TALK); + SendQuad(Connection, StatementID); + SendString(Connection, Sender); + SendByte(Connection, (uint8)Mode); + if(Mode == TALK_GAMEMASTER_REQUEST){ + SendQuad(Connection, (uint32)Data); + } + SendString(Connection, Text); + FinishSendData(Connection); +} + +void SendTalk(TConnection *Connection, uint32 StatementID, + const char *Sender, int Mode, int Channel, const char *Text){ + if(Mode != TALK_CHANNEL_CALL + && Mode != TALK_GAMEMASTER_CHANNELCALL + && Mode != TALK_HIGHLIGHT_CHANNELCALL + && Mode != TALK_ANONYMOUS_CHANNELCALL){ + error("SendTalk (C): Ungültiger Modus %d.\n", Mode); + return; + } + + if(Sender == NULL){ + error("SendTalk (C): Sender ist NULL.\n"); + return; + } + + if(Text == NULL){ + error("SendTalk (C): Text ist NULL.\n"); + return; + } + + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_TALK); + SendQuad(Connection, StatementID); + if(Mode != TALK_ANONYMOUS_CHANNELCALL){ + SendString(Connection, Sender); + }else{ + SendString(Connection, ""); + } + SendByte(Connection, (uint8)Mode); + SendWord(Connection, (uint16)Channel); + SendString(Connection, Text); + FinishSendData(Connection); +} + +void SendTalk(TConnection *Connection, uint32 StatementID, + const char *Sender, int Mode, int x, int y, int z, const char *Text){ + if(Mode != TALK_SAY + && Mode != TALK_WHISPER + && Mode != TALK_YELL + && Mode != TALK_ANIMAL_LOW + && Mode != TALK_ANIMAL_LOUD){ + error("SendTalk: Ungültiger Modus %d.\n", Mode); + return; + } + + if(Sender == NULL){ + error("SendTalk (K): Sender ist NULL.\n"); + return; + } + + if(Text == NULL){ + error("SendTalk (K): Text ist NULL.\n"); + return; + } + + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_TALK); + SendQuad(Connection, StatementID); + SendString(Connection, Sender); + SendByte(Connection, (uint8)Mode); + SendWord(Connection, (uint16)x); + SendWord(Connection, (uint16)y); + SendByte(Connection, (uint8)z); + SendString(Connection, Text); + FinishSendData(Connection); +} + +void SendChannels(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + return; + } + + int Channels = GetNumberOfChannels(); + bool OwnChannel = MayOpenChannel(Player->ID); + int NumAvailable = 0; + bool *Available = (bool*)alloca(Channels * sizeof(bool)); + for(int Channel = 0; Channel < Channels; Channel += 1){ + Available[Channel] = ChannelAvailable(Channel, Player->ID); + if(Available[Channel]){ + NumAvailable += 1; + } + } + + if(OwnChannel){ + NumAvailable += 1; + } + + // TODO(fusion): The original function wouldn't limit the maximum number + // of available channels. It is unlikely any player would be invited to + // more channels than an uint8 can hold but there is no reason not to + // maintain packet coherency. If this value wraps and we still add all + // available channels, the whole packet will get dropped and I'm not sure + // but the client may also assert. + if(NumAvailable > UINT8_MAX){ + NumAvailable = UINT8_MAX; + } + + SendByte(Connection, SV_CMD_CHANNELS); + SendByte(Connection, (uint8)NumAvailable); + + if(OwnChannel){ + SendWord(Connection, 0xFFFF); + SendString(Connection, "Private Chat Channel"); + NumAvailable -= 1; + } + + for(int Channel = 0; Channel < Channels; Channel += 1){ + if(NumAvailable <= 0){ + break; + } + + if(Available[Channel]){ + SendWord(Connection, (uint16)Channel); + SendString(Connection, GetChannelName(Channel, Player->ID)); + NumAvailable -= 1; + } + } + + FinishSendData(Connection); +} + +void SendOpenChannel(TConnection *Connection, int Channel){ + if(!BeginSendData(Connection)){ + return; + } + + if(Channel == CHANNEL_RULEVIOLATIONS){ + error("SendOpenChannel: Kanal ist GM-Request-Queue.\n"); + return; + } + + if(Channel < 0 || Channel >= GetNumberOfChannels()){ + error("SendOpenChannel: Ungültiger Kanal %d.\n", Channel); + return; + } + + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + return; + } + + SendByte(Connection, SV_CMD_OPEN_CHANNEL); + SendWord(Connection, (uint16)Channel); + SendString(Connection, GetChannelName(Channel, Player->ID)); + FinishSendData(Connection); +} + +void SendPrivateChannel(TConnection *Connection, const char *Name){ + if(!BeginSendData(Connection)){ + return; + } + + if(Name == NULL){ + error("SendPrivateChannel: Name ist NULL.\n"); + return; + } + + SendByte(Connection, SV_CMD_PRIVATE_CHANNEL); + SendString(Connection, Name); + FinishSendData(Connection); +} + +void SendOpenRequest(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_OPEN_REQUEST); + SendWord(Connection, (uint16)CHANNEL_RULEVIOLATIONS); + FinishSendData(Connection); +} + +void SendDeleteRequest(TConnection *Connection, const char *Name){ + if(!BeginSendData(Connection)){ + return; + } + + if(Name == NULL){ + error("SendDeleteRequest: Name ist NULL.\n"); + return; + } + + SendByte(Connection, SV_CMD_DELETE_REQUEST); + SendString(Connection, Name); + FinishSendData(Connection); +} + +void SendFinishRequest(TConnection *Connection, const char *Name){ + if(!BeginSendData(Connection)){ + return; + } + + if(Name == NULL){ + error("SendFinishRequest: Name ist NULL.\n"); + return; + } + + SendByte(Connection, SV_CMD_FINISH_REQUEST); + SendString(Connection, Name); + FinishSendData(Connection); +} + +void SendCloseRequest(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_CLOSE_REQUEST); + FinishSendData(Connection); +} + +void SendOpenOwnChannel(TConnection *Connection, int Channel){ + if(!BeginSendData(Connection)){ + return; + } + + if(Channel < 0 || Channel >= GetNumberOfChannels()){ + error("SendOpenOwnChannel: Ungültiger Kanal %d.\n", Channel); + return; + } + + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + return; + } + + SendByte(Connection, SV_CMD_OPEN_OWN_CHANNEL); + SendWord(Connection, (uint16)Channel); + SendString(Connection, GetChannelName(Channel, Player->ID)); + FinishSendData(Connection); +} + +void SendCloseChannel(TConnection *Connection, int Channel){ + if(!BeginSendData(Connection)){ + return; + } + + SendByte(Connection, SV_CMD_CLOSE_CHANNEL); + SendWord(Connection, (uint16)Channel); + FinishSendData(Connection); +} + +void SendMessage(TConnection *Connection, int Mode, const char *Text, ...){ + if(Mode != TALK_ADMIN_MESSAGE + && Mode != TALK_EVENT_MESSAGE + && Mode != TALK_LOGIN_MESSAGE + && Mode != TALK_STATUS_MESSAGE + && Mode != TALK_INFO_MESSAGE + && Mode != TALK_FAILURE_MESSAGE){ + error("SendMessage: Ungültiger Modus %d.\n", Mode); + return; + } + + if(!BeginSendData(Connection)){ + return; + } + + char Buffer[4096]; + va_list ap; + va_start(ap, Text); + vsnprintf(Buffer, sizeof(Buffer), Text, ap); + va_end(ap); + + SendByte(Connection, SV_CMD_MESSAGE); + SendByte(Connection, (uint8)Mode); + SendString(Connection, Buffer); + FinishSendData(Connection); +} + +void SendSnapback(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + // TODO(fusion): Sometimes we check, sometimes we don't. + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + return; + } + + SendByte(Connection, SV_CMD_SNAPBACK); + SendByte(Connection, (uint8)Player->Direction); + FinishSendData(Connection); +} + +void SendOutfit(TConnection *Connection){ + if(!BeginSendData(Connection)){ + return; + } + + TPlayer *Player = Connection->GetPlayer(); + if(Player == NULL){ + return; + } + + uint16 FirstOutfit = (Player->Sex == 1) ? 128 : 136; + uint16 LastOutfit = (Player->Sex == 1) ? 131 : 139; + if(CheckRight(Player->ID, PREMIUM_ACCOUNT)){ + LastOutfit += 3; + } + + SendByte(Connection, SV_CMD_OUTFIT); + SendOutfit(Connection, Player->OrgOutfit); + SendWord(Connection, FirstOutfit); + SendWord(Connection, LastOutfit); + FinishSendData(Connection); +} + +void SendBuddyData(TConnection *Connection, uint32 CharacterID, const char *Name, bool Online){ + if(!BeginSendData(Connection)){ + return; + } + + if(Name == NULL){ + return; + } + + SendByte(Connection, SV_CMD_BUDDY_DATA); + SendWord(Connection, CharacterID); + SendString(Connection, Name); + SendByte(Connection, (Online ? 1 : 0)); + FinishSendData(Connection); +} + +void SendBuddyStatus(TConnection *Connection, uint32 CharacterID, bool Online){ + if(!BeginSendData(Connection)){ + return; + } + + if(Online){ + SendByte(Connection, SV_CMD_BUDDY_ONLINE); + }else{ + SendByte(Connection, SV_CMD_BUDDY_OFFLINE); + } + SendWord(Connection, CharacterID); + FinishSendData(Connection); +} + +void BroadcastMessage(int Mode, const char *Text, ...){ + char Message[1024]; + va_list ap; + va_start(ap, Text); + vsnprintf(Message, sizeof(Message), Text, ap); + va_end(ap); + + TConnection *Connection = GetFirstConnection(); + while(Connection != NULL){ + if(Connection->Live()){ + SendMessage(Connection, Mode, Message); + } + Connection = GetNextConnection(); + } +} + +void DeleteGamemasterRequest(const char *Name){ + if(Name == NULL){ + error("DeleteGamemasterRequest: Name ist NULL.\n"); + return; + } + + TConnection *Connection = GetFirstConnection(); + while(Connection != NULL){ + if(Connection->Live()){ + TPlayer *Player = Connection->GetPlayer(); + if(Player != NULL && ChannelSubscribed(CHANNEL_RULEVIOLATIONS, Player->ID)){ + SendDeleteRequest(Connection, Name); + } + } + Connection = GetNextConnection(); + } +} + +void InitSending(void){ + FirstSendingConnection = NULL; +} + +void ExitSending(void){ + // no-op +} diff --git a/src/stubs.hh b/src/stubs.hh index 61114c4..a7bd80d 100644 --- a/src/stubs.hh +++ b/src/stubs.hh @@ -18,7 +18,6 @@ typedef void TSendMailsFunction(TPlayerData *PlayerData); extern void AbortWriter(void); extern void AddBuddyOrder(TCreature *Creature, uint32 CharacterID); extern void RemoveBuddyOrder(TCreature *Creature, uint32 BuddyID); -extern void BroadcastMessage(int Mode, const char *Text, ...) ATTR_PRINTF(2, 3); extern void ChangeNPCState(TCreature *Npc, int NewState, bool Stimulus); extern void CharacterDeathOrder(TCreature *Creature, int OldLevel, uint32 Offender, const char *Remark, bool Unjustified); @@ -27,7 +26,6 @@ extern void ConvinceMonster(TCreature *Master, TCreature *Slave); extern void ChallengeMonster(TCreature *Challenger, TCreature *Monster); extern TCreature *CreateMonster(int Race, int x, int y, int z, int Home, uint32 Master, bool ShowEffect); extern void DecrementIsOnlineOrder(uint32 CharacterID); -extern void DeleteGamemasterRequest(const char *Name); extern void GetExitPosition(uint16 HouseID, int *x, int *y, int *z); extern int GetOrderBufferSpace(void); extern const char *GetHouseName(uint16 HouseID); @@ -54,60 +52,7 @@ extern void SavePlayerData(TPlayerData *Slot); extern bool LoadPlayerData(TPlayerData *Slot); extern bool PlayerDataExists(uint32 CharacterID); extern void SavePlayerDataOrder(void); -extern void SendAll(void); -extern void SendAmbiente(TConnection *Connection); -extern void SendBodyInventory(TConnection *Connection, uint32 CreatureID); -extern void SendBuddyData(TConnection *Connection, uint32 CharacterID, const char *Name, bool Online); -extern void SendBuddyStatus(TConnection *Connection, uint32 CharacterID, bool Online); -extern void SendClearTarget(TConnection *Connection); -extern void SendContainer(TConnection *Connection, int ContainerNr); -extern void SendCloseChannel(TConnection *Connection, int ChannelID); -extern void SendCloseContainer(TConnection *Connection, int ContainerNr); -extern void SendCloseRequest(TConnection *Connection); -extern void SendCloseTrade(TConnection *Connection); -extern void SendCreatureHealth(TConnection *Connection, uint32 CreatureID); -extern void SendCreatureLight(TConnection *Connection, uint32 CreatureID); -extern void SendCreatureOutfit(TConnection *Connection, uint32 CreatureID); -extern void SendCreatureSpeed(TConnection *Connection, uint32 CreatureID); -extern void SendCreatureSkull(TConnection *Connection, uint32 CreatureID); -extern void SendCreatureParty(TConnection *Connection, uint32 CreatureID); -extern void SendDeleteField(TConnection *Connection, int x, int y, int z, Object Obj); -extern void SendAddField(TConnection *Connection, int x, int y, int z, Object Obj); -extern void SendChangeField(TConnection *Connection, int x, int y, int z, Object Obj); -extern void SendDeleteInContainer(TConnection *Connection, int ContainerNr, Object Obj); -extern void SendCreateInContainer(TConnection *Connection, int ContainerNr, Object Obj); -extern void SendChangeInContainer(TConnection *Connection, int ContainerNr, Object Obj); -extern void SendDeleteInventory(TConnection *Connection, int Position); -extern void SendSetInventory(TConnection *Connection, int Position, Object Obj); -extern void SendEditList(TConnection *Connection, uint8 ListType, uint32 ID, const char *Text); -extern void SendFinishRequest(TConnection *Connection, const char *Name); -extern void SendFullScreen(TConnection *Connection); -extern void SendFloors(TConnection *Connection, bool Up); -extern void SendInitGame(TConnection *Connection, uint32 CharacterID); -extern void SendRights(TConnection *Connection); -extern void SendOutfit(TConnection *Connection); -extern void SendGraphicalEffect(TConnection *Connection, int x, int y, int z, int Type); -extern void SendTextualEffect(TConnection *Connection, int x, int y, int z, int Color, const char *Text); -extern void SendMissileEffect(TConnection *Connection, int OrigX, int OrigY, int OrigZ, int DestX, int DestY, int DestZ, int Type); -extern void SendRow(TConnection *Connection, int Direction); extern void SendMails(TPlayerData *PlayerData); -extern void SendMarkCreature(TConnection *Connection, uint32 CreatureID, int Color); -extern void SendMessage(TConnection *Connection, int Mode, const char *Text, ...) ATTR_PRINTF(3, 4); -extern void SendMoveCreature(TConnection *Connection, uint32 CreatureID, int x, int y, int z); -extern void SendOpenOwnChannel(TConnection *Connection, int Channel); -extern void SendPing(TConnection *Connection); -extern void SendPlayerData(TConnection *Connection); -extern void SendPlayerSkills(TConnection *Connection); -extern void SendPlayerState(TConnection *Connection, uint8 State); -extern void SendResult(TConnection *Connection, RESULT r); -extern void SendSnapback(TConnection *Connection); -extern void SendTalk(TConnection *Connection, uint32 StatementID, - const char *Sender, int Mode, const char *Text, int Data); -extern void SendTalk(TConnection *Connection, uint32 StatementID, - const char *Sender, int Mode, int Channel, const char *Text); -extern void SendTalk(TConnection *Connection, uint32 StatementID, - const char *Sender, int Mode, int x,int y,int z, const char *Text); -extern void SendTradeOffer(TConnection *Connection, const char *Name, bool OwnOffer, Object Obj); extern void ShowGuestList(uint16 HouseID, TPlayer *Player, char *Buffer); extern void ShowSubownerList(uint16 HouseID, TPlayer *Player, char *Buffer); extern void ShowNameDoor(Object Door, TPlayer *Player, char *Buffer); |
