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(); }
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(); }
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; }
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; }
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(); }
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; } }
void WriteString(const char* String) { for(uint64_t i = 0; String[i] != '\0'; i++) { WriteChar((uint8_t) String[i]); } }
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); } }
void WriteString(char *data) //发送一个字符串 { while(*data) { WriteChar(*data++); } }
static void WordFlush(WINDOW *w) { int i; for(i = 0; i < OutC; i++) WriteChar(w, OutWord[i]); OutC = 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); }
void Console::Write(char *szString) { while((*szString) != 0) { WriteChar(*(szString++)); } }
BOOL BEEncoder::WriteRawString(LPSTRING s) { int nlength = s->GetLength(); for (int i = 0; i < nlength; i++) WriteChar(s->GetAt(i)); return TRUE; }
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; } }
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(','); }
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; }
static void do_PutLine(int x, int y, const char *line) { if (x >= 0 && y >= 0) MoveCursor(x, y); while (*line) WriteChar(*line++); }
void LcdConsole::WriteBuffer(const char *buf, const size_t length) { for (size_t i = length; i; --i) { WriteChar(*buf++); } }
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; }
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 ®ion = 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(); } }
BOOL BEEncoder::EncodeString(LPSTRING s) { WriteRawInt(s->GetLength()); WriteChar(':'); WriteRawString(s); return TRUE; }
void LcdConsole::WriteString(const char *str) { while (*str) { WriteChar(*str); ++str; } }
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(); }
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]); } }
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(); }
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; } }
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]); }
void cProtocol125::SendGameMode(eGameMode a_GameMode) { cCSLock Lock(m_CSPacket); WriteByte(PACKET_CHANGE_GAME_STATE); WriteByte(3); WriteChar((char)a_GameMode); Flush(); }
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(); }
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(); }