Пример #1
0
void cProtocol125::SendBlockAction(int a_BlockX, int a_BlockY, int a_BlockZ, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
{
	UNUSED(a_BlockType);
	
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_BLOCK_ACTION);
	WriteInt  (a_BlockX);
	WriteShort((short)a_BlockY);
	WriteInt  (a_BlockZ);
	WriteChar (a_Byte1);
	WriteChar (a_Byte2);
	Flush();
}
Пример #2
0
void cProtocol125::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, char a_RelY, char a_RelZ)
{
	ASSERT(a_Entity.GetUniqueID() != m_Client->GetPlayer()->GetUniqueID());  // Must not send for self
	
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ENT_REL_MOVE_LOOK);
	WriteInt (a_Entity.GetUniqueID());
	WriteChar(a_RelX);
	WriteChar(a_RelY);
	WriteChar(a_RelZ);
	WriteChar((char)((a_Entity.GetYaw()   / 360.f) * 256));
	WriteChar((char)((a_Entity.GetPitch() / 360.f) * 256));
	Flush();
}
Пример #3
0
static int  WriteOptionString( const TidyOptionImpl* option,
                               ctmbstr sval, StreamOut* out )
{
  ctmbstr cp = option->name;
  while ( *cp )
      WriteChar( *cp++, out );
  WriteChar( ':', out );
  WriteChar( ' ', out );
  cp = sval;
  while ( *cp )
      WriteChar( *cp++, out );
  WriteChar( '\n', out );
  return 0;
}
Пример #4
0
void WriteEndFullTag(void)
{
	char *etag = NULL;

	if ((etag = CurrFull->find(CurrDepth)) == NULL)
		return;

	long etype = GetCurrEtype(etag);

	// if pending text, strip trailing space until after end tag
	if (PendingText)
		PendingText = WriteTextWithoutTrailingSpace(PendingText);

	if (DoFull && DoPara) {
		// if ending block, and in wrapped text, close the p
		if ((etype == 1)
		 && WrappedText) {
			WriteCode("</p>");
			WrappedText = false;
		}
	}

	bool skiptag = false;

	if (DoMin && DoPara) {
		if (SkippedPTag
		 && !stricmp(etag, "p")) {
			skiptag = true;
			SkippedPTag = false;
		}
	}

	if (!skiptag) {
		WriteChar('<');
		WriteChar('/');
		WriteText(etag);
		WriteChar('>');
	}

	if (((etag = CurrShort->find(CurrDepth)) != NULL)
	 && !stricmp(etag, CurrElems->find(CurrDepth))) {
		CurrElems->remove(CurrDepth);
		CurrEtypes->remove(CurrDepth);
	}
	CurrFull->remove(CurrDepth);
	CurrShortEnd->remove(CurrDepth);
	CurrShort->remove(CurrDepth);
	LastFullEndDepth = --CurrDepth;
}
Пример #5
0
void cProtocol125::SendPlayerSpawn(const cPlayer & a_Player)
{
	const cItem & HeldItem = a_Player.GetEquippedItem();
	cCSLock Lock(m_CSPacket);
	WriteByte	 (PACKET_PLAYER_SPAWN);
	WriteInt   (a_Player.GetUniqueID());
	WriteString(a_Player.GetName());
	WriteInt   ((int)(a_Player.GetPosX() * 32));
	WriteInt   ((int)(a_Player.GetPosY() * 32));
	WriteInt   ((int)(a_Player.GetPosZ() * 32));
	WriteChar  ((char)((a_Player.GetYaw()   / 360.f) * 256));
	WriteChar  ((char)((a_Player.GetPitch() / 360.f) * 256));
	WriteShort (HeldItem.IsEmpty() ? 0 : HeldItem.m_ItemType);
	Flush();
}
Пример #6
0
int main(int argc, char* argv[]) {
    if (!ParseParams(argc, argv))
        return 1;

    if (FILE* f_src = fopen(params.srcFile, "rb")) {
        FILE* f_dest = stdout;
        //if (f_dest) {
        if (params.header) {
            fprintf(f_dest, "unsigned char %s[] = {", params.hArrName);
            WriteNewLine(f_dest);
        }
        int c = fgetc(f_src);
        if (!feof(f_src)) {
            unsigned int n = 0;
            while (true) {
                WriteChar(f_dest, c);
                c = fgetc(f_src);
                if (feof(f_src))
                    break;
                WriteLineTerm(f_dest, n++);
            }
            while(params.nul--) {
                WriteLineTerm(f_dest, n++);
                WriteChar(f_dest, 0);
            }
        } else {
            fprintf(stderr,"Warning: The input file was empty. Empty file generated.\n");
        }
        if (params.header) {
            WriteNewLine(f_dest);
            fputs("};", f_dest);
        }
        while(params.line--) {
            WriteNewLine(f_dest);
        }
        //fclose(f_dest);
        fclose(f_src);
        return 0;
        //} else {
        //fclose(f_src);
        //fprintf(stderr,"Error: Can't create file '%s'\n",params.dstFile);
        //return 3;
        //}
    } else {
        fprintf(stderr,"Error: Can't open file '%s'\n",params.srcFile);
        return 2;
    }
}
Пример #7
0
	void WriteString(const char* String)
	{
		for(uint64_t i = 0; String[i] != '\0'; i++)
		{
			WriteChar((uint8_t) String[i]);
		}
	}
Пример #8
0
void cProtocol125::WriteItem(const cItem & a_Item)
{
	short ItemType = a_Item.m_ItemType;
	ASSERT(ItemType >= -1);  // Check validity of packets in debug runtime
	if (ItemType <= 0)
	{
		// Fix, to make sure no invalid values are sent.
		ItemType = -1;
	}
	
	WriteShort(ItemType);
	if (a_Item.IsEmpty())
	{
		return;
	}
	
	WriteChar (a_Item.m_ItemCount);
	WriteShort(a_Item.m_ItemDamage);
	
	if (cItem::IsEnchantable(a_Item.m_ItemType))
	{
		// TODO: Implement enchantments
		WriteShort(-1);
	}
}
Пример #9
0
void WriteString(char *data)		//发送一个字符串
{
	while(*data)
	{
		WriteChar(*data++);
	}
}
Пример #10
0
static void WordFlush(WINDOW *w)
{
	int i;
	for(i = 0; i < OutC; i++)
		WriteChar(w, OutWord[i]);
	OutC = 0;
}
Пример #11
0
int WritePropValue(char *v, int second, U_SHORT flags, FILE *sfile)
{
	U_SHORT fl;

	if(!v)	return(TRUE);
	
	if(second)
		saveputc(sfile, ':');

	fl = option_softlinebreaks && (flags & SPLIT_SAVE);

	while(*v)
	{
		if(!WriteChar(sfile, *v, flags & PVT_SIMPLE))
			return(FALSE);

		if(fl && (save_linelen > MAXTEXT_LINELEN))		/* soft linebreak */
		{
			if (*v == '\\' && *(v-1) != '\\')
								 /* if we have just written a single '\' then  */
				v--;					/* treat it as soft linebreak and set  */
			else						/* v back so that it is written again. */
				saveputc(sfile, '\\');	/* else insert soft linebreak */
			saveputc(sfile, '\n');
		}

		v++;
	}

	return(TRUE);
}
Пример #12
0
void Console::Write(char *szString)
{
	while((*szString) != 0)
	{
		WriteChar(*(szString++));
	}
}
Пример #13
0
BOOL BEEncoder::WriteRawString(LPSTRING s)
{
    int nlength = s->GetLength();
    for (int i = 0; i < nlength; i++)
        WriteChar(s->GetAt(i));
    return TRUE;
}
Пример #14
0
void Write(Dictionary<TK, TV> const &a) {
    Write("Count = ");
    var len = a.Count();
    Write(len);
    WriteChar(NewLine);
    if (len) {
        var p = a.UsedNodeHead();
Lab1:
        Write(p->Key);
        Write(", ");
        Write(p->Value);
        WriteChar(NewLine);
        if ((p = p->UsedNext))
            goto Lab1;
    }
}
Пример #15
0
void ResourceWriter::WriteHex(uint8_t tmp)
{
  const char* const digits = "0123456789abcdef";
  WriteChar('0');
  WriteChar('x');
  if (tmp < 16)
  {
    WriteChar(digits[tmp]);
  }
  else
  {
    WriteChar(digits[tmp >> 4]);
    WriteChar(digits[tmp & 0xf]);
  }
  WriteChar(',');
}
Пример #16
0
template<UInt32 len> void Write(Char  const (&s)[len]) {
    for (UInt32 i = 0; i < len; ++i)
        if (var c = s[i])
            WriteChar(c);
        else
            break;
}
Пример #17
0
static void do_PutLine(int x, int y, const char *line)
{
    if (x >= 0 && y >= 0)
	MoveCursor(x, y);
    while (*line)
	WriteChar(*line++);
}
Пример #18
0
void LcdConsole::WriteBuffer(const char *buf, const size_t length)
{
    for (size_t i = length; i; --i)
    {
        WriteChar(*buf++);
    }
}
Пример #19
0
void WriteString(const u32 *CharValue, int startX, int startY) {
	int character = 0;
	while (*CharValue != 0) {
		WriteChar(*CharValue, startX + character, startY, TEXT_COLOR, BG_COLOR);
		CharValue++;
		character += 40;
}
Пример #20
0
void LcdConsole::WriteChar(const char ch)
{
    if (ch == '\n')
    {
        do
        {
            WriteChar(' ');
        } while (m_cursor_x != 0);
    }
    else
    {
        CellData *cell = &m_buffer[m_cursor_y * m_max_text_x + m_cursor_x];
        if (cell->ch != ch || cell->color != m_typewriter.GetTextColor()
                || cell->bg_color != m_typewriter.GetBgColor())
        {
            const Lcd::Rect &region = m_lcd->GetRegion();
            m_lcd->SetRegion(Lcd::Rect{
                m_cursor_x * LcdTypewriter::GetFontW() + m_region.x,
                m_cursor_y * LcdTypewriter::GetFontH() + m_region.y,
                LcdTypewriter::GetFontW(), LcdTypewriter::GetFontH()});
            m_typewriter.WriteChar(ch);
            m_lcd->SetRegion(region);

            cell->ch = ch;
            cell->color = m_typewriter.GetTextColor();
            cell->bg_color = m_typewriter.GetBgColor();
        }
        NewChar();
    }
}
Пример #21
0
BOOL BEEncoder::EncodeString(LPSTRING s)
{
    WriteRawInt(s->GetLength());
    WriteChar(':');
    WriteRawString(s);
    return TRUE;
}
Пример #22
0
void LcdConsole::WriteString(const char *str)
{
    while (*str)
    {
        WriteChar(*str);
        ++str;
    }
}
Пример #23
0
void cProtocol125::SendRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_REMOVE_ENTITY_EFFECT);
	WriteInt (a_Entity.GetUniqueID());
	WriteChar((char)a_EffectID);
	Flush();
}
Пример #24
0
void SocketWBuffer::WriteUint32(uint32_t v) {
    char buf[35];
    int chw;
    snprintf(buf, 32, "%u%n", v, &chw);
    for (int i = 0; i < chw; ++i) {
        WriteChar(buf[i]);
    }
}
Пример #25
0
void cProtocol125::SendEntityAnimation(const cEntity & a_Entity, char a_Animation)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ANIMATION);
	WriteInt (a_Entity.GetUniqueID());
	WriteChar(a_Animation);
	Flush();
}
Пример #26
0
void RestoreCursorBackgroundText()
	{
	if (!mouse.hidden && mouse.background)
		{
		WriteChar(mouse.backposx, mouse.backposy, vPC_rLodsb(BIOSMEM_SEG, BIOSMEM_CURRENT_PAGE), mouse.backChar, mouse.backAttr, true);
		mouse.background = false;
		}
	}
Пример #27
0
INLINE void Write(Char  const * const &s,   UInt32 const &len) {
	if (s == NULL) {
		WriteNull();
		return;
	}
	for(UInt32 i = 0; i < len; ++i)
		WriteChar(s[i]);
}
Пример #28
0
void cProtocol125::SendGameMode(eGameMode a_GameMode)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_CHANGE_GAME_STATE);
	WriteByte(3);
	WriteChar((char)a_GameMode);
	Flush();
}
Пример #29
0
void cProtocol125::SendEntityStatus(const cEntity & a_Entity, char a_Status)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_ENT_STATUS);
	WriteInt (a_Entity.GetUniqueID());
	WriteChar(a_Status);
	Flush();
}
Пример #30
0
void cProtocol125::SendMapColumn(int a_ID, int a_X, int a_Y, const Byte * a_Colors, unsigned int a_Length)
{
	cCSLock Lock(m_CSPacket);

	WriteByte (PACKET_ITEM_DATA);
	WriteShort(E_ITEM_MAP);
	WriteShort((short)a_ID);
	WriteShort((short)(3 + a_Length));

	WriteByte(0);
	WriteChar((char)a_X);
	WriteChar((char)a_Y);
	
	SendData((const char *)a_Colors, a_Length);

	Flush();
}