예제 #1
0
파일: XConfig.cpp 프로젝트: SeargeDP/OBS
void  XElement::AddHexList(CTSTR lpName, List<DWORD> &HexList)
{
    assert(lpName);

    for(DWORD i=0; i<HexList.Num(); i++)
        AddHex(lpName, HexList[i]);
}
size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext *pCtx, const cell_t *params, int *param)
{
	if (!buffer || !maxlen)
	{
		return 0;
	}

	int arg;
	int args = params[0];
	char *buf_p;
	char ch;
	int flags;
	int width;
	int prec;
	int n;
	char sign;
	const char *fmt;
	size_t llen = maxlen - 1;

	buf_p = buffer;
	arg = *param;
	fmt = format;

	while (true)
	{
		// run through the format string until we hit a '%' or '\0'
		for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++)
		{
			*buf_p++ = ch;
			llen--;
		}
		if ((ch == '\0') || (llen <= 0))
		{
			goto done;
		}

		// skip over the '%'
		fmt++;

		// reset formatting state
		flags = 0;
		width = 0;
		prec = -1;
		sign = '\0';

rflag:
		ch = *fmt++;
reswitch:
		switch(ch)
		{
		case '-':
			{
				flags |= LADJUST;
				goto rflag;
			}
		case '.':
			{
				n = 0;
				while(is_digit((ch = *fmt++)))
				{
					n = 10 * n + (ch - '0');
				}
				prec = (n < 0) ? -1 : n;
				goto reswitch;
			}
		case '0':
			{
				flags |= ZEROPAD;
				goto rflag;
			}
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			{
				n = 0;
				do
				{
					n = 10 * n + (ch - '0');
					ch = *fmt++;
				} while(is_digit(ch));
				width = n;
				goto reswitch;
			}
		case 'c':
			{
				CHECK_ARGS(0);
				if (!llen)
				{
					goto done;
				}
				char *c;
				pCtx->LocalToString(params[arg], &c);
				*buf_p++ = *c;
				llen--;
				arg++;
				break;
			}
		case 'b':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddBinary(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'd':
		case 'i':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddInt(&buf_p, llen, static_cast<int>(*value), width, flags);
				arg++;
				break;
			}
		case 'u':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddUInt(&buf_p, llen, static_cast<unsigned int>(*value), width, flags);
				arg++;
				break;
			}
		case 'f':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddFloat(&buf_p, llen, sp_ctof(*value), width, prec, flags);
				arg++;
				break;
			}
		case 'L':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				char buffer[255];
				if (*value)
				{
					CPlayer *player = g_Players.GetPlayerByIndex(*value);
					if (!player || !player->IsConnected())
					{
						return pCtx->ThrowNativeError("Client index %d is invalid", *value);
					}
					const char *auth = player->GetAuthString();
					if (!auth || auth[0] == '\0')
					{
						auth = "STEAM_ID_PENDING";
					}
					int userid = engine->GetPlayerUserId(player->GetEdict());
					UTIL_Format(buffer, 
						sizeof(buffer), 
						"%s<%d><%s><>", 
						player->GetName(),
						userid,
						auth);
				}
				else
				{
					UTIL_Format(buffer,
						sizeof(buffer),
						"Console<0><Console><Console>");
				}
				AddString(&buf_p, llen, buffer, width, prec);
				arg++;
				break;
			}
		case 'N':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);

				const char *name = "Console";
				if (*value)
				{
					CPlayer *player = g_Players.GetPlayerByIndex(*value);
					if (!player || !player->IsConnected())
					{
						return pCtx->ThrowNativeError("Client index %d is invalid", *value);
					}
					name = player->GetName();
				}
				AddString(&buf_p, llen, name, width, prec);
				arg++;
				break;
			}
		case 's':
			{
				CHECK_ARGS(0);
				char *str;
				int err;
				if ((err=pCtx->LocalToString(params[arg], &str)) != SP_ERROR_NONE)
				{
					pCtx->ThrowNativeErrorEx(err, "Could not deference string");
					return 0;
				}
				AddString(&buf_p, llen, str, width, prec);
				arg++;
				break;
			}
		case 'T':
			{
				CHECK_ARGS(1);
				char *key;
				bool error;
				size_t res;
				cell_t *target;
				pCtx->LocalToString(params[arg++], &key);
				pCtx->LocalToPhysAddr(params[arg++], &target);
				res = Translate(buf_p, llen, pCtx, key, *target, params, &arg, &error);
				if (error)
				{
					return 0;
				}
				buf_p += res;
				llen -= res;
				break;
			}
		case 't':
			{
				CHECK_ARGS(0);
				char *key;
				bool error;
				size_t res;
				cell_t target = g_SourceMod.GetGlobalTarget();
				pCtx->LocalToString(params[arg++], &key);
				res = Translate(buf_p, llen, pCtx, key, target, params, &arg, &error);
				if (error)
				{
					return 0;
				}
				buf_p += res;
				llen -= res;
				break;
			}
		case 'X':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				flags |= UPPERDIGITS;
				AddHex(&buf_p, llen, static_cast<unsigned int>(*value), width, flags);
				arg++;
				break;
			}
		case 'x':
			{
				CHECK_ARGS(0);
				cell_t *value;
				pCtx->LocalToPhysAddr(params[arg], &value);
				AddHex(&buf_p, llen, static_cast<unsigned int>(*value), width, flags);
				arg++;
				break;
			}
		case '%':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		case '\0':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = '%';
				llen--;
				goto done;
			}
		default:
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		}
	}

done:
	*buf_p = '\0';
	*param = arg;
	return (maxlen - llen - 1);
}
size_t gnprintf(char *buffer, size_t maxlen, const char *format, void **args)
{
	if (!buffer || !maxlen)
	{
		return 0;
	}

	int arg = 0;
	char *buf_p;
	char ch;
	int flags;
	int width;
	int prec;
	int n;
	char sign;
	const char *fmt;
	size_t llen = maxlen - 1;

	buf_p = buffer;
	fmt = format;

	while (true)
	{
		// run through the format string until we hit a '%' or '\0'
		for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++)
		{
			*buf_p++ = ch;
			llen--;
		}
		if ((ch == '\0') || (llen <= 0))
		{
			goto done;
		}

		// skip over the '%'
		fmt++;

		// reset formatting state
		flags = 0;
		width = 0;
		prec = -1;
		sign = '\0';

rflag:
		ch = *fmt++;
reswitch:
		switch(ch)
		{
		case '-':
			{
				flags |= LADJUST;
				goto rflag;
			}
		case '.':
			{
				n = 0;
				while(is_digit((ch = *fmt++)))
				{
					n = 10 * n + (ch - '0');
				}
				prec = (n < 0) ? -1 : n;
				goto reswitch;
			}
		case '0':
			{
				flags |= ZEROPAD;
				goto rflag;
			}
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			{
				n = 0;
				do
				{
					n = 10 * n + (ch - '0');
					ch = *fmt++;
				} while(is_digit(ch));
				width = n;
				goto reswitch;
			}
		case 'c':
			{
				if (!llen)
				{
					goto done;
				}
				char *c = (char *)args[arg];
				*buf_p++ = *c;
				llen--;
				arg++;
				break;
			}
		case 'b':
			{
				int *value = (int *)args[arg];
				AddBinary(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'd':
		case 'i':
			{
				int *value = (int *)args[arg];
				AddInt(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'u':
			{
				unsigned int *value = (unsigned int *)args[arg];
				AddUInt(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'f':
			{
				float *value = (float *)args[arg];
				AddFloat(&buf_p, llen, *value, width, prec, flags);
				arg++;
				break;
			}
		case 's':
			{
				const char *str = (const char *)args[arg];
				AddString(&buf_p, llen, str, width, prec);
				arg++;
				break;
			}
		case 'X':
			{
				unsigned int *value = (unsigned int *)args[arg];
				flags |= UPPERDIGITS;
				AddHex(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case 'x':
			{
				unsigned int *value = (unsigned int *)args[arg];
				AddHex(&buf_p, llen, *value, width, flags);
				arg++;
				break;
			}
		case '%':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		case '\0':
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = '%';
				llen--;
				goto done;
			}
		default:
			{
				if (!llen)
				{
					goto done;
				}
				*buf_p++ = ch;
				llen--;
				break;
			}
		}
	}

done:
	*buf_p = '\0';

	return (maxlen - llen - 1);
}
예제 #4
0
파일: listing.c 프로젝트: cc65/cc65
void CreateListing (void)
/* Create the listing */
{
    FILE* F;
    Fragment* Frag;
    ListLine* L;
    char HeaderBuf [LINE_HEADER_LEN+1];

    /* Open the real listing file */
    F = fopen (SB_GetConstBuf (&ListingName), "w");
    if (F == 0) {
        Fatal ("Cannot open listing file '%s': %s",
               SB_GetConstBuf (&ListingName),
               strerror (errno));
    }

    /* Reset variables, print the header for the first page */
    PageNumber = 0;
    PrintPageHeader (F, LineList);

    /* Terminate the header buffer. The last byte will never get overwritten */
    HeaderBuf [LINE_HEADER_LEN] = '\0';

    /* Walk through all listing lines */
    L = LineList;
    while (L) {

        char* Buf;
        char* B;
        unsigned Count;
        unsigned I;
        char* Line;

        /* If we should not output this line, go to the next */
        if (L->Output == 0) {
            L = L->Next;
            continue;
        }

        /* If we don't have a fragment list for this line, things are easy */
        if (L->FragList == 0) {
            PrintLine (F, MakeLineHeader (HeaderBuf, L), L->Line, L);
            L = L->Next;
            continue;
        }

        /* Count the number of bytes in the complete fragment list */
        Count = 0;
        Frag = L->FragList;
        while (Frag) {
            Count += Frag->Len;
            Frag = Frag->LineList;
        }

        /* Allocate memory for the given number of bytes */
        Buf = xmalloc (Count*2+1);

        /* Copy an ASCII representation of the bytes into the buffer */
        B = Buf;
        Frag = L->FragList;
        while (Frag) {

            /* Write data depending on the type */
            switch (Frag->Type) {

                case FRAG_LITERAL:
                    for (I = 0; I < Frag->Len; ++I) {
                        B = AddHex (B, Frag->V.Data[I]);
                    }
                    break;

                case FRAG_EXPR:
                case FRAG_SEXPR:
                    B = AddMult (B, 'r', Frag->Len*2);
                    break;

                case FRAG_FILL:
                    B = AddMult (B, 'x', Frag->Len*2);
                    break;

                default:
                    Internal ("Invalid fragment type: %u", Frag->Type);

            }

            /* Next fragment */
            Frag = Frag->LineList;

        }

        /* Limit the number of bytes actually printed */
        if (L->ListBytes != 0) {
            /* Not unlimited */
            if (Count > L->ListBytes) {
                Count = L->ListBytes;
            }
        }

        /* Output the data. The format of a listing line is:
        **
        **      PPPPPPm I  11 22 33 44
        **
        ** where
        **
        **      PPPPPP  is the PC
        **      m       is the mode ('r' or empty)
        **      I       is the include level
        **      11 ..   are code or data bytes
        */
        Line = L->Line;
        B    = Buf;
        while (Count) {

            unsigned    Chunk;
            char*       P;

            /* Prepare the line header */
            MakeLineHeader (HeaderBuf, L);

            /* Get the number of bytes for the next line */
            Chunk = Count;
            if (Chunk > 4) {
                Chunk = 4;
            }
            Count -= Chunk;

            /* Increment the program counter. Since we don't need the PC stored
            ** in the LineList object for anything else, just increment this
            ** variable.
            */
            L->PC += Chunk;

            /* Copy the bytes into the line */
            P = HeaderBuf + 11;
            for (I = 0; I < Chunk; ++I) {
                *P++ = *B++;
                *P++ = *B++;
                *P++ = ' ';
            }

            /* Output this line */
            PrintLine (F, HeaderBuf, Line, L);

            /* Don't output a line twice */
            Line = "";

        }

        /* Delete the temporary buffer */
        xfree (Buf);

        /* Next line */
        L = L->Next;

    }

    /* Close the listing file */
    (void) fclose (F);
}
예제 #5
0
파일: HexDefs.cpp 프로젝트: molip/Eclipsoid
HexDefs::HexDefs()
{
	HexDef* p;
	p = AddHex(1, "111111", 4); 
	p->SetArtifact(true);
	p->SetDiscovery(true);
	p->AddSquare(299,  92, SquareType::Science);
	p->AddSquare(250,  92, SquareType::Science, true);
	p->AddSquare( 95, 235, SquareType::Materials);
	p->AddSquare( 95, 176, SquareType::Materials, true);
	p->AddSquare(218, 328, SquareType::Any);
	p->AddSquare(270, 328, SquareType::Any);
	//AddShip(ShipType::GCDS, Colour::None);

	p = AddHex(101, "011111", 2);
	p->SetAncients(1);
	p->AddSquare(310, 113, SquareType::Money);
	p->AddSquare(134,  87, SquareType::Materials);
	p->AddSquare(182,  87, SquareType::Materials, true);
	
	p = AddHex(102, "101101", 3);
	p->SetArtifact(true);
	p->AddSquare(138, 266, SquareType::Science);
	p->AddSquare(205, 266, SquareType::Science, true);

	p = AddHex(103, "111011", 2);
	p->AddSquare(195, 271, SquareType::Money, true);
	p->AddSquare(286, 293, SquareType::Any);

	p = AddHex(104, "110110", 2);
	p->SetAncients(2);
	p->AddSquare(322, 104, SquareType::Money);
	p->AddSquare(275, 104, SquareType::Money, true);
	p->AddSquare(124, 287, SquareType::Science);
	p->AddSquare(124, 238, SquareType::Science, true);

	p = AddHex(105, "111101", 3);
	p->SetAncients(1);
	p->SetArtifact(true);
	p->AddSquare(281,  83, SquareType::Money);
	p->AddSquare( 84, 220, SquareType::Science);
	p->AddSquare(296, 288, SquareType::Materials, true);

	p = AddHex(106, "111100", 2);
	p->AddSquare(167, 144, SquareType::Science);
	p->AddSquare(267, 125, SquareType::Materials);
		
	p = AddHex(107, "111101", 2);
	p->AddSquare(149, 252, SquareType::Money);
	p->AddSquare(243, 123, SquareType::Science, true);
	p->AddSquare(253, 269, SquareType::Materials, true);

	p = AddHex(108, "110110", 2);
	p->SetAncients(2);
	p->AddSquare(135, 143, SquareType::Money, true);
	p->AddSquare(247,  84, SquareType::Science);
	p->AddSquare(273, 316, SquareType::Any);

	p = AddHex(201, "010101");
	p->AddSquare(145, 241, SquareType::Money);
	p->AddSquare(204, 123, SquareType::Materials);

	p = AddHex(202, "010101");
	p->AddSquare(186, 311, SquareType::Science);
	p->AddSquare(186, 260, SquareType::Science, true);

	p = AddHex(203, "110101");
	p->SetAncients(2);
	p->AddSquare(158, 306, SquareType::Money);
	p->AddSquare(285, 298, SquareType::Science);
	p->AddSquare(182,  87, SquareType::Materials);

	p = AddHex(204, "110101", 2);
	p->SetAncients(1);
	p->SetArtifact(true);
	p->AddSquare(166, 76, SquareType::Money, true);
	p->AddSquare(174, 300, SquareType::Materials, true);
	p->AddSquare(294, 116, SquareType::Any);

	p = AddHex(205, "001110");
	p->AddSquare(171, 116, SquareType::Money);
	p->AddSquare(223, 116, SquareType::Money, true);
	p->AddSquare(253, 271, SquareType::Science, true);
		
	p = AddHex(206, "011101");
	p->SetDiscovery(true);
	p->AddSquare(167, 116, SquareType::Materials);

	p = AddHex(207, "110100");
	p->SetDiscovery(true);

	p = AddHex(208, "101101");
	p->SetDiscovery(true);

	p = AddHex(209, "110101");
	p->AddSquare(270, 108, SquareType::Money, true);
	p->AddSquare(159, 191, SquareType::Science);

	p = AddHex(210, "100101");
	p->AddSquare(243,  99, SquareType::Money);
	p->AddSquare(315, 253, SquareType::Materials);

	p = AddHex(211, "111100", 2);
	p->SetAncients(1);
	p->SetArtifact(true);
	p->AddSquare(283, 100, SquareType::Money);
	p->AddSquare(280, 307, SquareType::Materials, true);
	p->AddSquare(103, 261, SquareType::Any);
		
	p = AddStartHex(221);
	p->AddSquare(191, 102, SquareType::Money);
	p->AddSquare(247, 102, SquareType::Money, true);
	p->AddSquare(184, 294, SquareType::Science);
	p->AddSquare(133, 294, SquareType::Science, true);
	p->AddSquare(320, 291, SquareType::Materials);

	p = AddStartHex(222);
	p->AddSquare(198, 106, SquareType::Money);
	p->AddSquare(250, 106, SquareType::Money, true);
	p->AddSquare(268, 274, SquareType::Science);
	p->AddSquare(318, 274, SquareType::Science, true);
		
	p = AddStartHex(223);
	p->AddSquare(212, 105, SquareType::Money);
	p->AddSquare(271, 105, SquareType::Money, true);
	p->AddSquare(156, 192, SquareType::Science);
	p->AddSquare( 98, 192, SquareType::Science, true);
	p->AddSquare(299, 271, SquareType::Materials);
		
	p = AddStartHex(224);
	p->AddSquare(212, 112, SquareType::Money);
	p->AddSquare(156, 192, SquareType::Science);
	p->AddSquare( 98, 192, SquareType::Science, true);
	p->AddSquare(258, 279, SquareType::Materials, true);
		
	p = AddStartHex(225);
	p->AddSquare(169, 309, SquareType::Money);
	p->AddSquare(169, 256, SquareType::Money, true);
	p->AddSquare(285, 262, SquareType::Science);
	p->AddSquare(336, 262, SquareType::Science, true);
	p->AddSquare(169, 124, SquareType::Materials);
		
	p = AddStartHex(226);
	p->AddSquare(191, 107, SquareType::Money);
	p->AddSquare(158, 294, SquareType::Science);
	p->AddSquare(342, 262, SquareType::Materials);
		
	p = AddStartHex(227);
	p->AddSquare(276, 285, SquareType::Money);
	p->AddSquare(333, 285, SquareType::Money, true);
	p->AddSquare(224, 118, SquareType::Science);
	p->AddSquare(224,  69, SquareType::Science, true);
	p->AddSquare(126, 250, SquareType::Materials);
		
	p = AddStartHex(228);
	p->AddSquare(183, 110, SquareType::Money);
	p->AddSquare(169, 263, SquareType::Science);
	p->AddSquare(291, 282, SquareType::Materials, true);
		
	p = AddStartHex(229);
	p->AddSquare(132, 274, SquareType::Money);
	p->AddSquare(188, 274, SquareType::Money, true);
	p->AddSquare(278, 273, SquareType::Science);
	p->AddSquare(330, 273, SquareType::Science, true);
	p->AddSquare(289,  79, SquareType::Materials);
		
	p = AddStartHex(230);
	p->AddSquare(180, 107, SquareType::Money);
	p->AddSquare(235, 107, SquareType::Money, true);
	p->AddSquare(146, 285, SquareType::Science);
	p->AddSquare(341, 262, SquareType::Materials, true);
		
	p = AddStartHex(231);
	p->AddSquare(277, 265, SquareType::Money);
	p->AddSquare(335, 265, SquareType::Money, true);
	p->AddSquare(252, 112, SquareType::Science);
	p->AddSquare(194, 112, SquareType::Science, true);
	p->AddSquare(155, 279, SquareType::Materials);
	
	p = AddStartHex(232);
	p->AddSquare(230, 106, SquareType::Money, true);
	p->AddSquare(131, 210, SquareType::Science);
	p->AddSquare(310, 276, SquareType::Materials);
	p->AddSquare(251, 276, SquareType::Materials, true);
		
	p = AddHex(301, "101100", 2);
	p->SetAncients(2);
	p->SetArtifact(true);
	p->AddSquare(302, 102, SquareType::Money);
	p->AddSquare(112, 182, SquareType::Science);
	p->AddSquare(294, 218, SquareType::Materials, true);
		
	p = AddHex(302, "100110", 2);
	p->SetAncients(1);
	p->SetArtifact(true);
	p->AddSquare(277,  94, SquareType::Money, true);
	p->AddSquare(305, 304, SquareType::Materials);
		
	p = AddHex(303, "000101", 2);
	p->SetAncients(1);
	p->SetArtifact(true);
	p->AddSquare(215, 86, SquareType::Any);
		
	p = AddHex(304, "100100");
	p->AddSquare(165, 126, SquareType::Money, true);
	p->AddSquare(216, 281, SquareType::Materials);
		
	p = AddHex(305, "110100");
	p->SetAncients(1);
	p->AddSquare(133, 110, SquareType::Science);
	p->AddSquare(260, 299, SquareType::Materials);
		
	p = AddHex(306, "010100");
	p->AddSquare(260, 113, SquareType::Money);
	p->AddSquare(269, 284, SquareType::Materials);
		
	p = AddHex(307, "101100");
	p->AddSquare(219,  81, SquareType::Money);
	p->AddSquare(146, 251, SquareType::Science, true);
		
	p = AddHex(308, "001101");
	p->AddSquare(283, 118, SquareType::Science);
	p->AddSquare(155, 197, SquareType::Materials, true);
		
	p = AddHex(309, "100101");
	p->AddSquare(254, 126, SquareType::Money);
	p->AddSquare(145, 207, SquareType::Science, true);
		
	p = AddHex(310, "100100");
	p->AddSquare(264,  76, SquareType::Science);
	p->AddSquare(156, 248, SquareType::Materials);
		
	p = AddHex(311, "101100");
	p->SetDiscovery(true);
	p->AddSquare(288, 274, SquareType::Materials);
		
	p = AddHex(312, "110100");
	p->SetDiscovery(true);
	p->AddSquare(251, 97, SquareType::Materials);
		
	p = AddHex(313, "100100");
	p->SetDiscovery(true);
	p->AddSquare(263, 101, SquareType::Any);
		
	p = AddHex(314, "001110");
	p->SetDiscovery(true);
	p->AddSquare(101, 244, SquareType::Any);
		
	p = AddHex(315, "100101");
	p->SetDiscovery(true);
		
	p = AddHex(316, "110100");
	p->SetDiscovery(true);
		
	p = AddHex(317, "000110");
	p->AddSquare(167, 265, SquareType::Money);
	p->AddSquare(167, 316, SquareType::Money, true);
		
	p = AddHex(318, "001100");
	p->AddSquare(113, 236, SquareType::Materials, true);
	p->AddSquare(221, 106, SquareType::Any);
}
예제 #6
0
파일: HexDefs.cpp 프로젝트: molip/Eclipsoid
HexDef* HexDefs::AddStartHex(int id)
{
	HexDef* p = AddHex(id, "110110", 3);
	p->SetArtifact(true);
	return p;
}
예제 #7
0
파일: Dumpcis.c 프로젝트: geoffmcl/dump4
UINT	IsCisFile2( HFILE hf, LPSTR lpf, LPSTR lpb, DWORD len,
				  DWORD fsiz )
{
	UINT		ftype;
	int			i, j;
	PCISKHDR	pCisKey;
	PCISF1		pCisVis;
	char		c;
	LPSTR		lpd, lps;
	BYTE		bi, bl, rc, ri, bc;
	PVISHDR2	pV2;
	PVISBLK		pVis;
	BOOL		bDir;
	PVISIN1		pI1;
	PVISIN2		pI2;
	DWORD		max;

	ftype = 0;
	lpd = &gcDiagBuf[0];
	bi = bl = rc = ri = bc = 0;
	pVis = 0;
	pV2 = 0;
	bDir = FALSE;
	pI1 = 0;
	pI2 = 0;
	if( ( max = len ) &&
		( pCisKey = (PCISKHDR)lpb ) )
	{
		if( len > sizeof( CISKHDR ) )
		{
			for( i = 0; i < LCISKHDR; i++ )
			{
				if( lpb[i] != szCisKHdr[i] )
					break;
			}
			if( i == LCISKHDR )
			{
				if( ( pCisKey->ch_Stop == 0x1a ) &&
					( j = pCisKey->ch_Count ) )
				{
					ftype = CISKFILE;
				}
			}
		}
		if( ( ftype == 0 ) &&
			( len > sizeof( CISF1 ) ) )
		{
			pCisVis = (PCISF1)lpb;
			for( i = 0; i < LCISHDR; i++ )
			{
				if( lpb[i] != szVisHdr[i] )
					break;
			}
			if( i == LCISHDR )
			{
//					( ( c == 'K' ) || ( c == 'F' ) || ( c == 'J' ) ) )
				c = pCisVis->cf_Type;
				if( ( pCisVis->cf_V1a == 0x1a ) &&  // = 0x1a
					c )
				{
					// = ";"=PLX "K"=ART "F"=MSG "J"=PLX
					ftype = CISVFILE;
					lps = (LPSTR)((PCISF1)pCisVis + 1);
#ifdef	DIAGFILE
					sprintf( lpd, "Processing file [%s].", lpf );
					wrtit( lpd );
					strcpy( lpd, "Unknown 1: " );
					AddHex( lpd, pCisVis->cf_Type );  // = "K"=ART "F"=MSG "J"=PLX
					AddHex( lpd, pCisVis->cf_Unk1[0] );     // Unknown
					AddHex( lpd, pCisVis->cf_Unk1[1] );     // Unknown
					wrtit( lpd );
					strcpy( lpd, "HDT: 1 " );
					//AddHr( lpd, pCisVis->cf_TD1.tHr );
					//AddMin( lpd, pCisVis->cf_TD1.tMin );
					//AddSec( lpd, pCisVis->cf_TD1.tSec );
					//AddDay( lpd, pCisVis->cf_TD1.tDate.cDay );
					//AddMth( lpd, pCisVis->cf_TD1.tDate.cMth );
					//AddYr( lpd, pCisVis->cf_TD1.tDate.cYr );
					AddDT( lpd, &pCisVis->cf_TD1 );
					//wrtit( lpd );
					//strcpy( lpd, "Header DT: 2 = " );
					//AddHr( lpd, pCisVis->cf_TD2.tHr );
					//AddMin( lpd, pCisVis->cf_TD2.tMin );
					//AddSec( lpd, pCisVis->cf_TD2.tSec );
					//AddDay( lpd, pCisVis->cf_TD2.tDate.cDay );
					//AddMth( lpd, pCisVis->cf_TD2.tDate.cMth );
					//AddYr( lpd, pCisVis->cf_TD2.tDate.cYr );
					strcat( lpb, " 2 " );
					AddDT( lpd, &pCisVis->cf_TD2 );
					wrtit( lpd );
					strcpy( lpd, "Unknown 2: " );
					AddHex( lpd, pCisVis->cf_Unk2[0] );     // Unknown
					AddHex( lpd, pCisVis->cf_Unk2[1] );     // Unknown
					AddHex( lpd,
						(BYTE)(((pCisVis->cf_Unk3 & 0xff00) >> 8) & 0xff) );
					AddHex( lpd,
						(BYTE)((pCisVis->cf_Unk3 & 0x00ff) & 0xff) );
					wrtit( lpd );
					strcpy( lpd, "Subject:[" );
					lps = (LPSTR)((PCISF1)pCisVis + 1);
					max -= sizeof( CISF1 );	// Reduce by HEADER
					bl = *lps++;	// Get SUBJECT Length
					max--;
					if( max == 0 )
						goto Dn_VBlock;
					szSubj[0] = 0;
					if( (DWORD)bl > max )
						bl = (BYTE)max;
					if( bl )
					{
						for( bi = 0; bi < bl; bi++ )
						{
							szSubj[bi] = lps[bi];
						}
						szSubj[bi] = 0;
						sprintf( (lpd + lstrlen( lpd )),
							"%s",
							&szSubj[0] );
						bDir = IsOut();
					}
					strcat( lpd, "]" );
					//wrtit( lpd );
					lps = lps + bl;
					// REDUCE SIZE
					max -= bl;
					if( max == 0 )
						goto Dn_VBlock;
					if( bl )
					{
						//strcpy( lpd, "Author:[" );
						strcat( lpd, " Author:[" );
						bl = *lps++;
						max--;	// Reduce max
						if( max == 0 )
							goto Dn_VBlock;
						if( (DWORD)bl > max )
							bl = (BYTE)max;
						if( bl )
						{
							for( bi = 0; bi < bl; bi++ )
							{
								sprintf( (lpd + lstrlen( lpd )),
									"%c",
									(lps[bi] & 0xff) );
							}
						}
						strcat( lpd, "]" );
						//wrtit( lpd );
						lps = lps + bl;
						// REDUCE SIZE
						max -= bl;
						if( max < 2 )
							goto Dn_VBlock;
						bl = *lps++;
						max--;
						if( (DWORD)bl > max )
							bl = (BYTE)max;
						if( bl )
						{
							//strcpy( lpd, "Address:[" );
							strcat( lpd, " Address:[" );
							for( bi = 0; bi < bl; bi++ )
							{
								sprintf( (lpd + lstrlen( lpd )),
									"%c",
									(lps[bi] & 0xff) );
							}
							strcat( lpd, "]" );
							wrtit( lpd );
							lps = lps + bl;
							max -= bl;
						}
					}
					if( max < 2 )
						goto Dn_VBlock;
					bl = *lps++;	// This SHOULD be ZERO!!!
					max--;
					if( (DWORD)bl > max )
						bl = (BYTE)max;
					*lpd = 0;
					while( bl )	// BUT if we do have something
					{
						strcpy( lpd, "Unknown String: [" );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								(lps[bi] & 0xff) );
						}
						strcat( lpd, "]" );
						wrtit( lpd );
						lps = lps + bl;
						max -= bl;
						if( max < 2 )
							goto Dn_VBlock;
						bl = *lps++;
						max--;
						if( (DWORD)bl > max )
							bl = (BYTE)max;
					}
					// We are now at Header 2
					pV2 = (PVISHDR2)lps;
					if( max < sizeof( VISHDR2 ) )
						goto Dn_VBlock;
					strcpy( lpd, "Unknown 3: " );
					AddHex( lpd, pV2->v2_Unk1 );
					AddHex( lpd, pV2->v2_Unk2 );
					strcat( lpd, "TD1 = " );
					AddDT( lpd, &pV2->v2_TD1 );
					strcat( lpd, "TD2 = " );
					AddDT( lpd, &pV2->v2_TD2 );
					wrtit( lpd );
					// Now Subject From Address
					lps = (LPSTR)((PVISHDR2)pV2 + 1);
					max -= sizeof( VISHDR2 );
					if( max < 2 )
						goto Dn_VBlock;
					bl = *lps++;
					max--;
					if( (DWORD)bl > max )
						bl = (BYTE)max;
					*lpd = 0;
					if( bl )
					{
						strcat( lpd, "Subj: [" );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								(lps[bi] & 0xff) );
						}
						strcat( lpd, "] " );
						lps += bl;
						max -= bl;
					}
					if( max < 2 )
						goto Dn_VBlock;
					bl = *lps++;
					max--;
					if( (DWORD)bl > max )
						bl = (BYTE)max;
					if( bl )
					{
						strcat( lpd, "From: [" );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								(lps[bi] & 0xff) );
						}
						strcat( lpd, "] " );
						lps += bl;
						max -= bl;
					}
					if( max < 2 )
						goto Dn_VBlock;
					bl = *lps++;
					max--;
					if( (DWORD)bl > max )
						bl = (BYTE)max;
					if( bl )
					{
						strcat( lpd, "Addr: [" );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								(lps[bi] & 0xff) );
						}
						strcat( lpd, "] " );
						lps += bl;
						max -= bl;
					}
					wrtit( lpd );
					if( max < 2 )
						goto Dn_VBlock;
					rc = *lps++;
					max--;
					sprintf( lpd, "Recipient(s) = %u",
						(rc & 0xff) );
					wrtit( lpd );
					ri = rc;
					if( max < 2 )
						goto Dn_VBlock;
					bl = *lps++;
					max--;
					if( (DWORD)bl > max )
						bl = (BYTE)max;
					while( ri-- )
					{
						if( (ri+1) == rc )
							strcpy( lpd, "To: [" );
						else
							strcpy( lpd, "Cc: [" );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								(lps[bi] & 0xff) );
						}
						strcat( lpd, "] " );
						lps += bl;
						max -= bl;
						if( max < 2 )
							goto Dn_VBlock;
						strcat( lpd, "] Addr: [" );
						bl = *lps++;
						max--;
						if( (DWORD)bl > max )
							bl = (BYTE)max;
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								(lps[bi] & 0xff) );
						}
						strcat( lpd, "]" );
						lps += bl;
						max -= bl;
						strcat( lpd, " +4 Unks " );
						if( max < 4 )
							goto Dn_VBlock;
						bi = 4;
						while( bi-- )
							AddHex( lpd, *lps++ );
						max -= 4;
						if( ri )	// If NOT last
						{
							if( max < 2 )
								goto Dn_VBlock;
							bl = *lps++;
							max--;
							if( (DWORD)bl > max )
								bl = (BYTE)max;
						}
						wrtit( lpd );
					}	// while recipients

					// We are now at HEADER 3
					if( bDir )	// If OUT
					{
						if( max < sizeof( VISBLK ) )
							goto Dn_VBlock;
						pVis = (PVISBLK)lps;
						//strcpy( lpd, "Unknown 4: " );
						//AddHex( lpd, pVis->vb_Unk1 );	// 00
						//AddHex( lpd, pVis->vb_Unk2 );	// 00
						//AddHex( lpd, pVis->vb_Unk3 );	// 00
						//wrtit( lpd );
						sprintf( lpd, "OUT: AutoFile = %s",
							(LPSTR)(pVis->vb_AutoFile ? "Yes " : "No ") );
						//wrtit( lpd );
						//strcpy( lpd, "Unknown 5: " );
						strcat( lpd, "Unknown 4: " );
						AddHex( lpd, pVis->vb_Unk5 );	// 00
						AddHex( lpd, pVis->vb_Unk6 );	// 00
						AddHex( lpd, pVis->vb_Unk7 );	// 00
						AddHex( lpd, pVis->vb_Unk8 );	// 29
						AddHex( lpd, pVis->vb_Unk9 );	// 00
						AddHex( lpd, pVis->vb_Unk10 );	// 02
						AddHex( lpd, pVis->vb_Unk11 );	// 00
						AddHex( lpd, pVis->vb_Unk12 );	// 00
						AddHex( lpd, pVis->vb_Unk13 );	// 00
						wrtit( lpd );
						strcpy( lpd, "Importance: " );
						switch( pVis->vb_Importance )	// 01=Normal 00=Low 02=High
						{
						case 0:
							strcat( lpd, "Low(0) " );
							break;
						case 1:
							strcat( lpd, "Normal(1) " );
							break;
						case 2:
							strcat( lpd, "Hight(2) " );
							break;
						default:
							strcat( lpd, "Unknown " );
							AddHex( lpd, pVis->vb_Importance );
							break;
						}
						strcat( lpd, "Sensitivity: " );
						switch( pVis->vb_Sensitive )	// 00=Normal 01=Personal 02=Private
//03=Confidential
						{
						case 0:
							strcat( lpd, "Normal(0) " );
							break;
						case 1:
							strcat( lpd, "Personal(1) " );
							break;
						case 2:
							strcat( lpd, "Private(2) " );
							break;
						case 3:
							strcat( lpd, "Confidential(3) " );
							break;
						default:
							strcat( lpd, "Unknown " );
							AddHex( lpd, pVis->vb_Sensitive );
							break;
						}
						sprintf( (lpd + lstrlen( lpd )),
							"Receipt=%s",
							(LPSTR)(pVis->vb_Receipt ? "Yes" : "No" ) );
						wrtit( lpd );
//	BYTE	vb_Unk17;	// 00
//	BYTE	vb_Payment;	// 08  0x40=Shared 0x80=Receiver 0x01=Rel.Date
//				//	0x02=Exp.Date
//	BYTE	vb_Unk19;	//
//	BYTE	vb_Unk20;
//	BYTE	vb_Unk21;
//	//BYTE	vb_RelDay;	// 1C 06 1B =
//	//BYTE	vb_RelMth;	// 28/06/97
//	//BYTE	vb_RelYr;	// NOTE: 0x01 in vb_Payment for Valid Date
//	CISDATE	vb_RelDate;
//	BYTE	vb_Unk25;
//	BYTE	vb_Unk26;
//	BYTE	vb_Unk27;
//	//BYTE	vb_ExpDay;	// 1C 06 1B =
//	//BYTE	vb_ExpMth;	// 28/06/97
//	//BYTE	vb_ExpYr;	// NOTE: 0x02 in vb_Payment for Valid Date
//	CISDATE	vb_ExpDate;
//	BYTE	vb_Unk31;	// 00
//	BYTE	vb_Attach;	// 01=None 02=Attached
//	BYTE	vb_Unk33;	// 01
//	WORD	vb_TxtLen;	// Length of TEXT content (incl @b, etc)
//	BYTE	vb_Unk36;
//	BYTE	vb_Unk37;
//	BYTE	vb_Unk38;
//	BYTE	vb_Unk39;
//	BYTE	vb_Unk40;	// 05
//	BYTE	vb_Unk41;
//	BYTE	vb_Unk42;
//	BYTE	vb_Unk43;
//	BYTE	vb_Unk44;
//	BYTE	vb_Unk45;
//	BYTE	vb_Attach2;	// 02
//	WORD	vb_AttLen;	// 00 1C for example
//	BYTE	vb_Unk49;
//	BYTE	vb_Unk50;
//	// Text starts - If NO attachment
//	// If attachement then
//	// 00 or Len,"Description"
//	// followed by Len,"FileName"
//	// Then 03 00 00 00 00
//	// Where 0x03=Binary 0x04=Text 0x02=GIF 0x06=JPEG
//	// Len(1C),"Path Name"
//	// Plus 00 00 00 00 00
//	// THEN TEXT
//}VISBLK;
////typedef VISBLK FAR * PVISBLK;
						lps = (LPSTR)((PVISBLK)pVis + 1);
						max -= sizeof( VISBLK );
					}
					else	// !bDir = IN
					{
						if( max < sizeof( VISIN1 ) )
							goto Dn_VBlock;
						pI1 = (PVISIN1)lps;
						strcpy( lpd, "IN: Unk: " );
						bl = sizeof( VISIN1 );
						for( bi = 0; bi < bl; bi++ )
						{
							AddHex( lpd, lps[bi] );
						}
						wrtit( lpd );
//typedef	struct {
//	BYTE	in_Unk1;
//	BYTE	in_Unk2;
//	BYTE	in_Unk3;
//	BYTE	in_Unk4;
//	BYTE	in_Unk5;
//	BYTE	in_Unk6;
//	BYTE	in_Unk7;
//	BYTE	in_Unk8;
//	BYTE	in_Unk9;
//}VISIN1;
//typedef VISIN1 * PVISIN1;
						lps += bl;
						max -= sizeof( VISIN1 );
						if( max < 2 )
							goto Dn_VBlock;
						bl = *lps++;
						max--;
						if( (DWORD)bl > max )
							bl = (BYTE)max;
						strcpy( lpd, "String [" );
						for( bi = 0; bi < bl; bi++ )
						{
// Len, "Text"
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								lps[bi] );
						}
						lps += bl;
						max -= bl;
						if( max < sizeof( VISIN2 ) )
							goto Dn_VBlock;
						pI2 = (PVISIN2)lps;
						bl = 5;
						strcpy( lpd, "Unknown: " );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								lps[bi] );
						}
						lps += bl;
//typedef	struct {
//	BYTE	i2_Unk1;
//	BYTE	i2_Unk2;
//	BYTE	i2_Unk3;
//	BYTE	i2_Unk4;
//	BYTE	i2_Unk5;
//	BYTE	i2_Unk6[16];
//	BYTE	i2_Unk22[16];
//}VISIN2;
//typedef	VISIN2 * PVISIN2;
						bl = 16;
						strcpy( lpd, "Unknown: " );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								lps[bi] );
						}
						lps += bl;
						bl = 16;
						strcpy( lpd, "Unknown: " );
						for( bi = 0; bi < bl; bi++ )
						{
							sprintf( (lpd + lstrlen( lpd )),
								"%c",
								lps[bi] );
						}
						lps += bl;
						lps = (LPSTR)((PVISIN2)pI2 + 1);
						max -= sizeof( VISIN2 );
					}
					// We have reached the TEXT
					strcpy( lpd, "Text:" );
					wrtit( lpd );
					bc = 0;		// Zero column
					*lpd = 0;
					while( max )
					{
						if( max > 16 )
							bl = 16;
						else
							bl = (BYTE)max;
						for( bi = 0; bi < bl; bi++ )
						{
							c = lps[bi];
							if( ( c == 0x0a ) || ( c == 0x09 ) )
							{
								// nothing to do here
							}
							else if( c < ' ' )
							{
								c = '*';	// switch to AST
							}
							if( c == 0x0a )
							{
								//sprintf( (lpd + lstrlen( lpd )),
								//	"%c",
								//	0x0d );
								//sprintf( (lpd + lstrlen( lpd )),
								//	"%c",
								//	c );
								bc = 0;	// Zero the column.
								wrtit( lpd );
								*lpd = 0;
							}
							else if( c == '@' )
							{
								if( lps[bi+1] == '@' )
								{
									sprintf( (lpd + lstrlen( lpd )),
										"%c",
										c );
									bc++;
									bi++;
								}
								else if( lps[bi+1] == 'b' )
								{
									//sprintf( (lpd + lstrlen( lpd )),
									//	"%c",
									//	0x0d );
									//sprintf( (lpd + lstrlen( lpd )),
									//	"%c",
									//	0x0a );
									bi++;
									bc = 0;	// Zero the column
									wrtit( lpd );
									*lpd = 0;
								}
								else
								{
									sprintf( (lpd + lstrlen( lpd )),
										"%c",
										c );
									bc++;	// Another column
									if( c == 0x09 )
									{
										bc += 6;
									}
								}
							}
							else
							{
								sprintf( (lpd + lstrlen( lpd )),
									"%c",
									c );
								bc++;	// Another column
								if( c == 0x09 )
								{
									bc += 6;
								}
							}
							if( bc > MINCOLS )
							{
								if( c == ' ' )
								{
									//sprintf( (lpd + lstrlen( lpd )),
									//	"%c",
									//	0x0d );
									//sprintf( (lpd + lstrlen( lpd )),
									//	"%c",
									//	0x0a );
									bc = 0;	// Zero the column
									wrtit( lpd );
									*lpd = 0;
								}
								else if( bc > MAXCOLS )
								{
									//sprintf( (lpd + lstrlen( lpd )),
									//	"%c",
									//	0x0d );
									//sprintf( (lpd + lstrlen( lpd )),
									//	"%c",
									//	0x0a );
									bc = 0;	// Zero the column
									wrtit( lpd );
									*lpd = 0;
								}
							}
						}	// for bl
						lps += bl;	// Bump the pointer
						max -= bl;	// and redcue the count
					}
					if( bc )
					{
						wrtit( lpd );
						*lpd = 0;
					}
#endif	// DIAGFILE
Dn_VBlock:
					strcpy( lpd, "Done VIS File" );
					wrtit( lpd );
				}	// verified VIS
			}	// i == LCISHDR ie "VIS000" present
예제 #8
0
파일: format.cpp 프로젝트: Arkshine/amxmodx
size_t atcprintf(D *buffer, size_t maxlen, const S *format, AMX *amx, cell *params, int *param)
{
	int		arg;
	int		args = params[0] / sizeof(cell);
	D		*buf_p;
	D		ch;
	int		flags;
	int		width;
	int		prec;
	int		n;
	//char	sign;
	const S	*fmt;
	size_t	llen = maxlen;

	buf_p = buffer;
	arg = *param;
	fmt = format;

	while (true)
	{
		// run through the format string until we hit a '%' or '\0'
		for (ch = static_cast<D>(*fmt); 
			llen && ((ch = static_cast<D>(*fmt)) != '\0' && ch != '%');
			fmt++)
		{
			*buf_p++ = static_cast<D>(ch);
			llen--;
		}
		if (ch == '\0' || llen <= 0)
			goto done;

		// skip over the '%'
		fmt++;

		// reset formatting state
		flags = 0;
		width = 0;
		prec = -1;
		//sign = '\0';

rflag:
		ch = static_cast<D>(*fmt++);
reswitch:
		switch(ch)
		{
		case '-':
			flags |= LADJUST;
			goto rflag;
		case '.':
			n = 0;
			while( is_digit( ( ch = static_cast<D>(*fmt++)) ) )
				n = 10 * n + ( ch - '0' );
			prec = n < 0 ? -1 : n;
			goto reswitch;
		case '0':
			flags |= ZEROPAD;
			goto rflag;
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			n = 0;
			do {
				n = 10 * n + ( ch - '0' );
				ch = static_cast<D>(*fmt++);
			} while( is_digit( ch ) );
			width = n;
			goto reswitch;
		case 'c':
			CHECK_ARGS(0);
			*buf_p++ = static_cast<D>(*get_amxaddr(amx, params[arg]));
			llen--;
			arg++;
			break;
		case 'b':
			CHECK_ARGS(0);
			AddBinary(&buf_p, llen, *get_amxaddr(amx, params[arg]), width, flags);
			arg++;
			break;
		case 'd':
		case 'i':
			CHECK_ARGS(0);
			AddInt(&buf_p, llen, *get_amxaddr(amx, params[arg]), width, flags);
			arg++;
			break;
		case 'u':
			CHECK_ARGS(0);
			AddUInt(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
			arg++;
			break;
		case 'f':
			CHECK_ARGS(0);
			AddFloat(&buf_p, llen, amx_ctof(*get_amxaddr(amx, params[arg])), width, prec, flags);
			arg++;
			break;
		case 'X':
			CHECK_ARGS(0);
			flags |= UPPERDIGITS;
			AddHex(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
			arg++;
			break;
		case 'x':
			CHECK_ARGS(0);
			AddHex(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
			arg++;
			break;
		case 'a':
			{
				CHECK_ARGS(0);
				// %a is passed a pointer directly to a cell string.
				cell* ptr=reinterpret_cast<cell*>(*get_amxaddr(amx, params[arg]));
				if (!ptr)
				{
					LogError(amx, AMX_ERR_NATIVE, "Invalid vector string handle provided (%d)", *get_amxaddr(amx, params[arg]));
					return 0;
				}

				AddString(&buf_p, llen, ptr, width, prec);
				arg++;
				break;
			}
		case 's':
			CHECK_ARGS(0);
			AddString(&buf_p, llen, get_amxaddr(amx, params[arg]), width, prec);
			arg++;
			break;
		case 'L':
		case 'l':
			{
				const char *lang;
				int len;
				if (ch == 'L')
				{
					CHECK_ARGS(1);
					auto currParam = params[arg++];
					lang = playerlang(*get_amxaddr(amx, currParam));
					if (!lang)
						lang = get_amxstring(amx, currParam, 2, len);
				}
				else
				{
					CHECK_ARGS(0);
					lang = playerlang(g_langMngr.GetDefLang());
				}
				const char *key = get_amxstring(amx, params[arg++], 3, len);
				const char *def = translate(amx, lang, key);
				if (!def)
				{
					static char buf[255];
					ke::SafeSprintf(buf, sizeof(buf), "ML_NOTFOUND: %s", key);
					def = buf;
				}
				size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
				buf_p += written;
				llen -= written;
				break;
			}
		case 'N':
			{
				CHECK_ARGS(0);
				cell *addr = get_amxaddr(amx, params[arg]);
				char buffer[255];
				if (*addr)
				{
					CPlayer *player = NULL;

					if (*addr >= 1 && *addr <= gpGlobals->maxClients)
					{
						player = GET_PLAYER_POINTER_I(*addr);
					}

					if (!player || !player->initialized)
					{
						LogError(amx, AMX_ERR_NATIVE, "Client index %d is invalid", *addr);
						return 0;
					}

					const char *auth = GETPLAYERAUTHID(player->pEdict);
					if (!auth || auth[0] == '\0')
					{
						auth = "STEAM_ID_PENDING";
					}

					int userid = GETPLAYERUSERID(player->pEdict);
					ke::SafeSprintf(buffer, sizeof(buffer), "%s<%d><%s><%s>", player->name.chars(), userid, auth, player->team.chars());
				}
				else
				{
					ke::SafeSprintf(buffer, sizeof(buffer), "Console<0><Console><Console>");
				}

				AddString(&buf_p, llen, buffer, width, prec);
				arg++;
				break;
			}
		case 'n':
			{
				CHECK_ARGS(0);
				cell *addr = get_amxaddr(amx, params[arg]);
				const char *name = "Console";

				if (*addr)
				{
					CPlayer *player = NULL;

					if (*addr >= 1 && *addr <= gpGlobals->maxClients)
					{
						player = GET_PLAYER_POINTER_I(*addr);
					}

					if (!player || !player->initialized)
					{
						LogError(amx, AMX_ERR_NATIVE, "Client index %d is invalid", *addr);
						return 0;
					}

					name = player->name.chars();
				}
			
				AddString(&buf_p, llen, name, width, prec);
				arg++;
				break;
			}
		case '%':
			*buf_p++ = static_cast<D>(ch);
			if (!llen)
				goto done;
			llen--;
			break;
		case '\0':
			*buf_p++ = static_cast<D>('%');
			if (!llen)
				goto done;
			llen--;
			goto done;
			break;
		default:
			*buf_p++ = static_cast<D>(ch);
			if (!llen)
				goto done;
			llen--;
			break;
		}
	}

done:
	*buf_p = static_cast<D>(0);
	*param = arg;

	/* if max buffer length consumed, make sure we don't truncate a multi-byte character */
	if (llen <= 0 && *(buf_p - 1) & 1 << 7)
	{
		llen += UTIL_CheckValidChar(buf_p - 1);
		*(buf_p - llen) = static_cast<D>(0);
	}

	return maxlen-llen;
}