Exemplo n.º 1
0
void CBuffer::UpdateInfo(tstring& s)
{
	tstring p;

	s = "";
	s += "MACRO-BUFFER INFO\n";
	s += "Network extender\n \n";

	if (GetPlayerOwner())
	{
		s += "Team: " + GetPlayerOwner()->GetPlayerName() + "\n";
		if (GetDigitanksPlayer() == DigitanksGame()->GetCurrentLocalDigitanksPlayer())
			s += " Friendly\n \n";
		else
			s += " Hostile\n \n";
	}
	else
	{
		s += "Team: Neutral\n \n";
	}

	if (IsConstructing())
	{
		s += "(Constructing)\n";
		s += tsprintf(tstring("Turns left: %d\n"), GetTurnsRemainingToConstruct());
		return;
	}

	s += tsprintf(tstring("Fleet Points: %d\n"), FleetPoints());
	s += tsprintf(tstring("Bandwidth: %.1f/turn\n"), Bandwidth());
	s += tsprintf(tstring("Network Size: %d\n"), (int)GetDataFlowRadius());
	s += tsprintf(tstring("Efficiency: %d\n"), (int)(GetChildEfficiency() * 100));
}
Exemplo n.º 2
0
char *
aopLiteralLong (value * val, int offset, int size)
{
	char *rs;
	union {
		float f;
		unsigned char c[4];
	}
	fl;

	if (!val) {
	  // assuming we have been warned before
	  val=constVal("0");
	}

	/* if it is a float then it gets tricky */
	/* otherwise it is fairly simple */
	if (!IS_FLOAT (val->type)) {
		unsigned long v = (unsigned long) floatFromVal (val);

		v >>= (offset * 8);
		switch (size) {
		case 1:
			tsprintf (buffer, "!immedbyte", (unsigned int) v & 0xff);
			break;
		case 2:
			tsprintf (buffer, "!immedword", (unsigned int) v & 0xffff);
			break;
		default:
			/* Hmm.  Too big for now. */
			assert (0);
		}
		rs = Safe_calloc (1, strlen (buffer) + 1);
		return strcpy (rs, buffer);
	}
Exemplo n.º 3
0
const char_t* TinfoDecVideo::TinfoValueDecVideo::getInputAspect(char_t *s, bool &wasChange, size_t buflen)
{
    unsigned int sar1 = 0, sar2 = 0, dar1 = 0, dar2 = 0;
    bool sarOk = deciV->getInputSAR(&sar1, &sar2) == S_OK;
    bool darOk = deciV->getInputDAR(&dar1, &dar2) == S_OK;
    if (oldSar1 != sar1 || oldSar2 != sar2 || oldDar1 != dar1 || oldDar2 != dar2) {
        if (sarOk) {
            tsprintf(s, _l("SAR: %u/%u, "), sar1, sar2);
        } else {
            tsprintf(s, _l("SAR: N/A, "));
        }

        if (darOk) {
            strncatf(s, buflen, _l("DAR: %u/%u"), dar1, dar2);
        } else {
            strncatf(s, buflen, _l("DAR: N/A"));
        }
        wasChange = true;
    }
    oldSar1 = sar1;
    oldSar2 = sar2;
    oldDar1 = dar1;
    oldDar2 = dar2;
    return s;
}
Exemplo n.º 4
0
/********************
  class scalarsettypedecl
  ********************/
scalarsettypedecl::scalarsettypedecl(expr * l, int lb)
  :typedecl(), named(FALSE), lexname(NULL), useless(TRUE)
{
  if (Error.CondError(!type_equal(l->gettype(), inttype),
                      "Only scalarsets of integer size allowed.") ||
      Error.CondError(!l->hasvalue(), "Scalarset size must be constants.")
     ) {
    left = lb;
    right = lb;
    numbits = 1;
    if (!args->no_compression) {
      bitsalloc = numbits;
    } else {
      bitsalloc = BYTES(numbits);
      if (left < 0 || right > 254 || numbits > 8)
        bitsalloc = 32;
    }
    mu_type = (left < 0 || right > 254 || numbits > 8 ?
               "mu__long" : "mu__byte");
    idvalues = symtab->declare(new lexid(tsprintf("scalarset_%u_v_error",
                                         scalarset_type_int++),
                                         0), new constdecl(lb++, this));
    // it is not set as scalarset variable because it is of size 1.
    // structure = typedecl::ScalarsetVariable;
    scalarsetlist = NULL;	// to be set when declaring ID : typeExpr
  } else {
    // setting size, numbits, left and right
    // const 0 is used for undefined value --> 0. lb, ... . ub
    int size = l->getvalue();
    if (size < 1)
      Error.Error("Scalarset size must be greater than zero.");
    numbits = CeilLog2(l->getvalue() + 1);
    left = lb;
    right = left + size - 1;
    if (!args->no_compression) {
      bitsalloc = numbits;
    } else {
      if (numbits > 31)
        Error.Error("Internal error, range is too large");
      bitsalloc = BYTES(numbits);
      if (left < 0 || right > 254 || numbits > 8)
        bitsalloc = 32;
    }
    mu_type = (left < 0 || right > 254 || numbits > 8 ?
               "mu__long" : "mu__byte");

    // set id strings
    // name may be changed if it is later explicitly given a type name
    int value = left;
    for (int i = 1; i <= size; i++) {
      symtab->declare(new lexid(tsprintf("scalarset_%u_v%u",
                                         scalarset_type_int, i), 0),
                      new constdecl(value++, this));
    }
    idvalues = symtab->getscope();
    if (size > 1)		// scalarset of size 1 is treated as normal enum
      structure = typedecl::ScalarsetVariable;
    scalarsetlist = NULL;	// to be set when declaring ID : typeExpr
  }
}
Exemplo n.º 5
0
static rd_kafka_resp_err_t on_new_consumer (rd_kafka_t *rk,
                                            const rd_kafka_conf_t *conf,
                                            void *ic_opaque,
                                            char *errstr, size_t errstr_size) {
        int i;

        for (i = 0 ; i < consumer_ic_cnt ; i++) {
                rd_kafka_interceptor_add_on_consume(
                        rk, tsprintf("on_consume:%d",i),
                        on_consume, (void *)(intptr_t)(on_consume_base | i));

                rd_kafka_interceptor_add_on_commit(
                        rk, tsprintf("on_commit:%d",i),
                        on_commit, (void *)(intptr_t)(on_commit_base | i));

                /* Add producer interceptors as well to make sure they
                 * are not called. */
                rd_kafka_interceptor_add_on_send(
                        rk, tsprintf("on_send:%d",i),
                        on_send, NULL);

                rd_kafka_interceptor_add_on_acknowledgement(
                        rk, tsprintf("on_acknowledgement:%d",i),
                        on_ack, NULL);
        }


        return RD_KAFKA_RESP_ERR_NO_ERROR;
}
Exemplo n.º 6
0
void CStructure::StartTurn()
{
	BaseClass::StartTurn();

	FindGround();

	if (!GetSupplier() && !dynamic_cast<CCPU*>(this))
	{
		if (GetPlayerOwner())
			GetPlayerOwner()->RemoveUnit(this);
		SetSupplier(NULL);
	}

	if (GetSupplier() && !GetSupplier()->GetPlayerOwner())
	{
		GetSupplier()->RemoveChild(this);
		if (GetPlayerOwner())
			GetPlayerOwner()->RemoveUnit(this);
		SetSupplier(NULL);
	}

	if (GetPlayerOwner() == NULL)
		return;

	if (IsConstructing())
	{
		m_iTurnsToConstruct--;

		if (m_iTurnsToConstruct == (size_t)0)
		{
			GetDigitanksPlayer()->AppendTurnInfo(tstring("Construction finished on ") + GetEntityName());
			CompleteConstruction();

			GetDigitanksPlayer()->AddActionItem(this, ACTIONTYPE_NEWSTRUCTURE);
		}
		else
			GetDigitanksPlayer()->AppendTurnInfo(tsprintf(tstring("Constructing ") + GetEntityName() + " (%d turns left)", m_iTurnsToConstruct.Get()));
	}

	if (IsUpgrading())
	{
		m_iTurnsToUpgrade--;

		if (m_iTurnsToUpgrade == (size_t)0)
		{
			GetDigitanksPlayer()->AppendTurnInfo(GetEntityName() + " finished upgrading.");

			UpgradeComplete();
		}
		else
			GetDigitanksPlayer()->AppendTurnInfo(tsprintf(tstring("Upgrading ") + GetEntityName() + " (%d turns left)", GetTurnsToUpgrade()));
	}
}
Exemplo n.º 7
0
/********************
  class ste
  ********************/
ste::ste(lexid * name, int scope, decl * value)
:name(name), scope(scope), value(value), next(NULL)
{
  if (value != NULL) {		/* IM: added condition on value, for external calls */
    /* a weirdness--we tell an object its name when we declare it. */
    if (name != NULL)
      value->name = name->getname();	/* loses a previous name for value. */
    if (value->getclass() != decl::Type)
      value->mu_name = tsprintf("mu_%s", value->name);
    else if (value != booltype)
      value->mu_name = tsprintf("mu_%d_%s", scope, value->name);
  }
}
Exemplo n.º 8
0
const char_t* TinfoDec::TinfoValueDec::getVal0(bool &wasChange, bool &splitline)
{
    switch (item->type) {
        case IDFF_OSDtype_encoderInfo:
            if (olds[0] == '\0') {
                char_t encoder[100] = _l("unknown");
                deciD->getEncoderInfo(encoder, 100);
                tsnprintf_s(s, countof(s), _TRUNCATE, _l("%s"), encoder);
                wasChange = true;
            }
            return s;
        case IDFF_OSDtype_shortInfo:
            deciD->getShortDescription(s, 512);
            wasChange = strcmp(s, olds) != 0;
            splitline = true;
            return s;
        case IDFF_OSDtype_movieSource:
            ff_strncpy(s, deciD->getDecoderName(), countof(s));
            wasChange = strcmp(s, olds) != 0;
            return s;
        case IDFF_OSDtype_bps: {
            int bps = deciD->getInputBitrate2();
            tsprintf(s, bps == -1 ? _l("N/A") : _l("%i kbps"), bps);
            wasChange = true;
            return s;
        }
        case IDFF_OSDtype_activePresetName: {
            deciD->getActivePresetName(s, countof(s));
            wasChange = strcmp(s, olds) != 0;
            return s;
        }
        default:
            return TinfoValueBase::getVal0(wasChange, splitline);
    }
}
Exemplo n.º 9
0
std::string tmppath(const char* prefix, const char* tmpdir)
{
    if( tmpdir == 0 || strlen(tmpdir) == 0 ) {
        tmpdir  = ::getenv("TMP");
        if( !tmpdir) 
            tmpdir = ::getenv("TEMP");
        #ifdef _WIN32
            if( !tmpdir) 
                tmpdir = "/Temp";
        #else
            if( !tmpdir) 
                tmpdir = "/tmp";
        #endif
    }       
    // TODO: it's somewhat weak radnomization strategy
    //       invent something better
    time_t t;
    time(&t);
    static bool srand_called = false;
    if( !srand_called ) {
        srand_called = true;
        ::srand(static_cast<unsigned>(t));
    }
    int stamp = ::rand() % 104729; // 104729 is some arbitrary prime number
    
    std::string sprefix;
    if( prefix == 0 || strlen(prefix) == 0) {
        sprefix = remove_extension(basename(get_exepath()));
    } else {
        sprefix = prefix;
    }
    const std::string result = tsprintf("%s/%s_%s_%s", tmpdir, sprefix, t, stamp);
    return result; 
}
Exemplo n.º 10
0
static void
wimlib_vmsg(const tchar *tag, const tchar *format,
	    va_list va, bool perror)
{
#if !defined(ENABLE_DEBUG)
	if (wimlib_print_errors)
#endif
	{
		int errno_save = errno;
		fflush(stdout);
		tfputs(tag, wimlib_error_file);
		tvfprintf(wimlib_error_file, format, va);
		if (perror && errno_save != 0) {
			tchar buf[64];
			int res;
			res = tstrerror_r(errno_save, buf, ARRAY_LEN(buf));
			if (res) {
				tsprintf(buf,
					 T("unknown error (errno=%d)"),
					 errno_save);
			}
		#ifdef WIN32
			if (errno_save == EBUSY)
				tstrcpy(buf, T("Resource busy"));
		#endif
			tfprintf(wimlib_error_file, T(": %"TS), buf);
		}
		tputc(T('\n'), wimlib_error_file);
		fflush(wimlib_error_file);
		errno = errno_save;
	}
}
Exemplo n.º 11
0
/********************
  class arraytypedecl
  ********************/
arraytypedecl::arraytypedecl(bool interleaved,
                             typedecl * indextype, typedecl * elementtype)
  :
  typedecl(), interleaved(interleaved), indextype(indextype),
  elementtype(elementtype)
{
  Error.CondError(!indextype->issimple(),
                  "Array index type must be a simple type.");
  if (elementtype->name == NULL)
    symtab->declare_global(ltable.enter(tsprintf("_type_%d", new_int()
                                                )
                                       ), elementtype);
  numbits = indextype->getsize() * elementtype->getbitsalloc();
  bitsalloc = numbits;

  // classify array type according to scalarset involvement
  if (indextype->getstructure() == typedecl::NoScalarset)
    structure = elementtype->getstructure();
  else if (indextype->getstructure() == typedecl::ScalarsetVariable)
    if (elementtype->getstructure() == typedecl::NoScalarset)
      structure = typedecl::ScalarsetArrayOfFree;
    else if (elementtype->getstructure() == typedecl::ScalarsetVariable)
      structure = typedecl::ScalarsetArrayOfScalarset;
    else
      structure = typedecl::Complex;
  else
    Error.Error("Complex type as index to array.");

}
Exemplo n.º 12
0
void CMiniBuffer::SetupMenu(menumode_t eMenuMode)
{
	if (GetDigitanksPlayer()->GetPrimaryCPU() != NULL)
		GetDigitanksPlayer()->GetPrimaryCPU()->SetupMenu(eMenuMode);

	CHUD* pHUD = DigitanksWindow()->GetHUD();
	tstring p;

	if (!IsConstructing() && !IsUpgrading() && CanStructureUpgrade())
	{
		pHUD->SetButtonListener(0, CHUD::BeginUpgrade);

		if (UpgradeCost() <= GetDigitanksPlayer()->GetPower())
		{
			pHUD->SetButtonTexture(0, "MacroBuffer");
			pHUD->SetButtonColor(0, Color(50, 50, 50));
		}

		tstring s;
		s += "UPGRADE TO MACRO-BUFFER\n \n";
		s += "Macro-Buffers provide larger Network radius and can be updated by installing downloaded updates. Upgrading will make this structure inactive until the upgrade is complete.\n \n";
		s += tsprintf(tstring("Turns to upgrade: %d Turns\n \n"), GetTurnsToUpgrade());
		s += "Shortcut: Q";

		pHUD->SetButtonInfo(0, s);
		pHUD->SetButtonTooltip(0, "Upgrade To Macro-Buffer");
	}
}
Exemplo n.º 13
0
void scalarsettypedecl::setupid(lexid * n)
{
  int i;
  ste *v;

  // set up type name
  setname(n);

  // rename id names
  for (i = getsize(), v = idvalues; i >= 1; i--, v = v->getnext()) {
    v->setname(new lexid(tsprintf("%s_%u", n->getname(), i), 0));
    v->getvalue()->name = v->getname()->getname();
    v->getvalue()->mu_name = tsprintf("mu_%s", v->getvalue()->name);
  }

}
Exemplo n.º 14
0
BOOL CSystemInfo::GetMemoryInfo()
{
	stdex::tString strValue = GetWmiInfo(TEXT("Select * from Win32_LogicalMemoryConfiguration"), TEXT("TotalPhysicalMemory"));
	if (strValue.empty())
		return FALSE;
	tsprintf(m_stCltHardInfo.szMemory, MAX_PATH, TEXT("%d"), __int64(_ttoi64(strValue.c_str())/1024. + .55));
	return TRUE;
}
Exemplo n.º 15
0
const char_t* TinfoDecVideo::TinfoValueDecVideo::getInputSize(char_t *s, bool &wasChange)
{
    unsigned int dx = 0, dy = 0;
    deciV->getAVIdimensions(&dx, &dy);
    if (oldDx != dx || oldDy != dy) {
        tsprintf(s, _l("%ux%u"), dx, dy);
        wasChange = true;
    }
    oldDx = dx;
    oldDy = dy;
    return s;
}
Exemplo n.º 16
0
bool CClientSocket::Connect(const char* pszHostname, int iPort)
{
	struct addrinfo hints;
	struct addrinfo *pResult;

	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = IPPROTO_TCP;

	tstring sPort = tsprintf("%d", iPort);

	int iResult = getaddrinfo(pszHostname, sPort.c_str(), &hints, &pResult);
	if ( iResult != 0 )
	{
		m_sError = "getaddrinfo() failed.";
		return false;
	}

	for (struct addrinfo *pCurrent = pResult; pCurrent != NULL; pCurrent=pCurrent->ai_next)
	{
		m_iSocket = socket(pCurrent->ai_family, pCurrent->ai_socktype, pCurrent->ai_protocol);
		if (m_iSocket == INVALID_SOCKET)
		{
			m_sError = "socket() failed";
#ifdef _WIN32
			WSACleanup();
#endif
			return false;
		}

		// Connect to server.
		iResult = connect( m_iSocket, (struct sockaddr *)pCurrent->ai_addr, (int)pCurrent->ai_addrlen);
		if (iResult == SOCKET_ERROR)
		{
			m_sError = "connect() failed";
#ifdef _WIN32
			closesocket(m_iSocket);
#else
			shutdown(m_iSocket, SHUT_RDWR);
			close(m_iSocket);
#endif
			iResult = INVALID_SOCKET;
			continue;
		}
		break;
	}

	freeaddrinfo(pResult);

	m_bOpen = true;
	return true;
}
Exemplo n.º 17
0
void TlevelsPage::TwidgetCurves::print(void)
{
    levelsPage->lbxClear(IDC_LBX_LEVELS_CURVES);
    for (size_t i=0; i<pt.size(); i++) {
        char_t s[30];
        tsprintf(s,_l("%u:[%li,%li]"),i,pt[i].x,pt[i].y);
        levelsPage->lbxAdd(IDC_LBX_LEVELS_CURVES,s,i);
    }
    if (dragpoint!=-1) {
        levelsPage->lbxSetCurSel(IDC_LBX_LEVELS_CURVES,dragpoint);
    }
}
Exemplo n.º 18
0
static rd_kafka_resp_err_t on_new_producer (rd_kafka_t *rk,
                                            const rd_kafka_conf_t *conf,
                                            void *ic_opaque,
                                            char *errstr, size_t errstr_size) {
        int i;

        for (i = 0 ; i < producer_ic_cnt ; i++) {
                rd_kafka_resp_err_t err;

                err = rd_kafka_interceptor_add_on_send(
                        rk, tsprintf("on_send:%d",i),
                        on_send, (void *)(intptr_t)(on_send_base | i));
                TEST_ASSERT(!err, "add_on_send failed: %s",
                            rd_kafka_err2str(err));

                err = rd_kafka_interceptor_add_on_acknowledgement(
                        rk, tsprintf("on_acknowledgement:%d",i),
                        on_ack, (void *)(intptr_t)(on_ack_base | i));
                TEST_ASSERT(!err, "add_on_ack.. failed: %s",
                            rd_kafka_err2str(err));


                /* Add consumer interceptors as well to make sure
                 * they are not called. */
                err = rd_kafka_interceptor_add_on_consume(
                        rk, tsprintf("on_consume:%d",i),
                        on_consume, NULL);
                TEST_ASSERT(!err, "add_on_consume failed: %s",
                            rd_kafka_err2str(err));


                err = rd_kafka_interceptor_add_on_commit(
                        rk, tsprintf("on_commit:%d",i),
                        on_commit, NULL);
                TEST_ASSERT(!err, "add_on_commit failed: %s",
                            rd_kafka_err2str(err));
        }

        return RD_KAFKA_RESP_ERR_NO_ERROR;
}
Exemplo n.º 19
0
void CCPU::UpdateInfo(tstring& s)
{
	tstring p;
	s = "";
	s += "CENTRAL PROCESSING UNIT\n";
	s += "Command center\n \n";

	if (GetDigitanksPlayer())
	{
		s += "Team: " + GetDigitanksPlayer()->GetPlayerName() + "\n";
		if (GetDigitanksPlayer() == DigitanksGame()->GetCurrentLocalDigitanksPlayer())
			s += " Friendly\n \n";
		else
			s += " Hostile\n \n";
	}
	else
	{
		s += "Team: Neutral\n \n";
	}

	if (IsProducing())
	{
		s += "[Producing Rogue]\n";
		s += tsprintf(tstring("Turns left: %d\n \n"), m_iTurnsToProduceRogue.Get());
	}

	s += tsprintf(tstring("Power: %.1f/turn\n"), Power());
	s += tsprintf(tstring("Fleet Points: %d\n"), FleetPoints());
	s += tsprintf(tstring("Bandwidth: %.1f/turn\n"), Bandwidth());
	s += tsprintf(tstring("Network Size: %d\n"), (int)GetDataFlowRadius());
	s += tsprintf(tstring("Efficiency: %d\n"), (int)(GetChildEfficiency() * 100));
}
Exemplo n.º 20
0
typedecl::typedecl(char *name)
  :decl(name),
   scalarsetlist(NULL),
   structure(NoScalarset),
   bitsalloc(0), already_generated_permute_function(FALSE)
{
  static int theTNum = 0;
  tNum = theTNum++;
  /* Add this typedecl into linked list */
  next = origin;
  origin = this;
  mu_name = tsprintf("mu_%s%d", name, tNum);
};
Exemplo n.º 21
0
void CHTTPPostSocket::SendHTTP11(const char* pszPage)
{
	tstring p;
	tstring sOutput;

	sOutput  = tstring("POST ") + pszPage + " HTTP/1.1\n";
	sOutput += "Host: " + m_sHostname + "\n";
	sOutput += tsprintf("Content-Length: %d\n", m_sPostContent.length());
	sOutput += "Content-Type: application/x-www-form-urlencoded\n\n";
	Send(sOutput);

	Send(m_sPostContent);
}
Exemplo n.º 22
0
/********************
  class vardecl
  ********************/
vardecl::vardecl(typedecl * type)
  :  decl(), type(type)
{
  if (type->name == NULL)
    symtab->declare_global(ltable.enter(tsprintf("_type_%d",
                                        new_int())), type);
  offset =::offset;
  ::offset += type->getbitsalloc();
  if (args->no_compression) {
    if (type->getbitsalloc() % 8 != 0)
      Error.Error("Internal error, byte aligned allocation failed.");
  }
}
Exemplo n.º 23
0
void CCharacterController::PreStep(btCollisionWorld* pCollisionWorld)
{
	int i = 0;
	while (RecoverFromPenetration(pCollisionWorld))
	{
		i++;

		if (i > phys_maxpenetrationrecover.GetInt())
		{
			TMsg(tsprintf("%f Character controller couldn't recover from penetration.\n", GameServer()->GetGameTime()));
			break;
		}
	}
}
Exemplo n.º 24
0
static int
get_capture_config(const tchar *config_file, struct capture_config *config,
		   int add_flags, const tchar *fs_source_path)
{
	int ret;
	tchar *tmp_config_file = NULL;

	memset(config, 0, sizeof(*config));

	/* For WIMBoot capture, check for default capture configuration file
	 * unless one was explicitly specified.  */
	if (!config_file && (add_flags & WIMLIB_ADD_FLAG_WIMBOOT)) {

		/* XXX: Handle loading file correctly when in NTFS volume.  */

		size_t len = tstrlen(fs_source_path) +
			     tstrlen(wimboot_cfgfile);
		tmp_config_file = MALLOC((len + 1) * sizeof(tchar));
		struct stat st;

		tsprintf(tmp_config_file, T("%"TS"%"TS),
			 fs_source_path, wimboot_cfgfile);
		if (!tstat(tmp_config_file, &st)) {
			config_file = tmp_config_file;
			add_flags &= ~WIMLIB_ADD_FLAG_WINCONFIG;
		} else {
			WARNING("\"%"TS"\" does not exist.\n"
				"          Using default capture configuration!",
				tmp_config_file);
		}
	}

	if (add_flags & WIMLIB_ADD_FLAG_WINCONFIG) {
		/* Use Windows default.  */
		if (config_file)
			return WIMLIB_ERR_INVALID_PARAM;
		ret = read_capture_config(T("wincfg"), wincfg,
					  sizeof(wincfg) - 1, config);
	} else if (config_file) {
		/* Use the specified configuration file.  */
		ret = read_capture_config(config_file, NULL, 0, config);
	} else {
		/* ... Or don't use any configuration file at all.  No files
		 * will be excluded from capture, all files will be compressed,
		 * etc.  */
		ret = 0;
	}
	FREE(tmp_config_file);
	return ret;
}
Exemplo n.º 25
0
void CLobbyPanel::CreateLobby(bool bOnline)
{
	m_bOnline = bOnline;

	CGameLobbyClient::SetLobbyUpdateCallback(&LobbyUpdateCallback);
	CGameLobbyClient::SetLobbyJoinCallback(&LobbyJoinCallback);
	CGameLobbyClient::SetLobbyLeaveCallback(&LobbyLeaveCallback);
	CGameLobbyClient::SetBeginGameCallback(&BeginGameCallback);

	const char* pszPort = DigitanksWindow()->GetCommandLineSwitchValue("--lobby-port");
	int iPort = pszPort?atoi(pszPort):0;

	m_iLobby = CGameLobbyServer::CreateLobby();
	CGameLobbyServer::SetListener(DigitanksLobbyListener());

	if (m_bOnline)
	{
		GameNetwork()->Disconnect();
		LobbyNetwork()->Disconnect();
		LobbyNetwork()->SetCallbacks(NULL, NULL, CGameLobbyServer::ClientEnterGame, CGameLobbyServer::ClientDisconnect);
		LobbyNetwork()->CreateHost(iPort);
	}

	CGameLobbyClient::S_JoinLobby(m_iLobby);
	CGameLobbyClient::S_UpdatePlayer(_T("host"), _T("1"));
	CGameLobbyClient::S_UpdateLobby(_T("gametype"), tsprintf(tstring("%d"), (gametype_t)lobby_gametype.GetInt()));

	if (!m_bOnline)
	{
		CGameLobbyClient::S_AddBot();
		CGameLobbyClient::S_AddBot();
		CGameLobbyClient::S_AddBot();
	}

	for (size_t i = 0; i < CGameLobbyClient::L_GetNumPlayers(); i++)
		CGameLobbyClient::S_UpdatePlayer(CGameLobbyClient::L_GetPlayer(i)->iID, _T("color"), tsprintf(tstring("%d"), i));

	if ((gametype_t)lobby_gametype.GetInt() == GAMETYPE_ARTILLERY)
		m_pDockPanel->SetDockedPanel(new CArtilleryGamePanel(true));
	else
		m_pDockPanel->SetDockedPanel(new CStrategyGamePanel(true));

	SetVisible(true);
	DigitanksWindow()->GetMainMenu()->SetVisible(false);

	m_bLayout = true;
}
Exemplo n.º 26
0
/**
 * @brief Produce messages according to compress \p codec
 */
static void produce_msgs (const char *topic, int partition, uint64_t testid,
                          int msgcnt, const char *broker_version,
                          const char *codec) {
        rd_kafka_conf_t *conf;
        rd_kafka_t *rk;
        int i;
        char key[128], buf[100];
        int msgcounter = msgcnt;

        test_conf_init(&conf, NULL, 0);
        rd_kafka_conf_set_dr_cb(conf, test_dr_cb);
        test_conf_set(conf, "compression.codec", codec);
        test_conf_set(conf, "broker.version.fallback", broker_version);
        if (strstr(broker_version, "0.10."))
                test_conf_set(conf, "api.version.request", "true");
        else
                test_conf_set(conf, "api.version.request", "false");
        /* Make sure to trigger a bunch of MessageSets */
        test_conf_set(conf, "batch.num.messages", tsprintf("%d", msgcnt/5));
        rk = test_create_handle(RD_KAFKA_PRODUCER, conf);

        for (i = 0 ; i < msgcnt ; i++) {
                rd_kafka_resp_err_t err;

                test_prepare_msg(testid, partition, i,
                                 buf, sizeof(buf), key, sizeof(key));

                err = rd_kafka_producev(rk,
                                        RD_KAFKA_V_TOPIC(topic),
                                        RD_KAFKA_V_VALUE(buf, sizeof(buf)),
                                        RD_KAFKA_V_KEY(key, sizeof(key)),
                                        RD_KAFKA_V_TIMESTAMP(my_timestamp.min),
                                        RD_KAFKA_V_MSGFLAGS(RD_KAFKA_MSG_F_COPY),
                                        RD_KAFKA_V_OPAQUE(&msgcounter),
                                        RD_KAFKA_V_END);
                if (err)
                        TEST_FAIL("producev() failed at msg #%d/%d: %s",
                                  i, msgcnt, rd_kafka_err2str(err));
        }

        TEST_SAY("Waiting for %d messages to be produced\n", msgcounter);
        while (msgcounter > 0)
                rd_kafka_poll(rk, 100);

        rd_kafka_destroy(rk);
}
Exemplo n.º 27
0
void CCPU::StartTurn()
{
	BaseClass::StartTurn();

	if (m_bProducing)
	{
		m_iTurnsToProduceRogue -= (size_t)1;
		if (m_iTurnsToProduceRogue == (size_t)0)
		{
			if (GameNetwork()->IsHost())
			{
				CDigitank* pTank = GameServer()->Create<CScout>("CScout");
				pTank->SetGlobalOrigin(GetGlobalOrigin());
				pTank->CalculateVisibility();
				GetDigitanksPlayer()->AddUnit(pTank);

				for (size_t x = 0; x < UPDATE_GRID_SIZE; x++)
				{
					for (size_t y = 0; y < UPDATE_GRID_SIZE; y++)
					{
						if (GetDigitanksPlayer()->HasDownloadedUpdate(x, y))
							pTank->DownloadComplete(x, y);
					}
				}

				// Face him toward the center.
				pTank->Move(pTank->GetGlobalOrigin() + -GetGlobalOrigin().Normalized()*15);
				pTank->Turn(VectorAngles(-GetGlobalOrigin().Normalized()));

				pTank->StartTurn();
			}

			m_bProducing = false;

			GetDigitanksPlayer()->AppendTurnInfo("Production finished on Rogue");

			GetDigitanksPlayer()->AddActionItem(this, ACTIONTYPE_UNITREADY);
		}
		else
		{
			GetDigitanksPlayer()->AppendTurnInfo(tsprintf(tstring("Producing Rogue (%d turns left)"), m_iTurnsToProduceRogue.Get()));
		}
	}
}
Exemplo n.º 28
0
bool Twindow::TwidgetSubclassTbr::onEdit(void)
{
    int idff=self->getTbrIdff(id,bind);
    TffdshowParamInfo info;
    memset(&info,0,sizeof(info));
    if (self->deci->getParamInfo(idff,&info)!=S_OK) {
        return false;
    }
    int min,max,val;
    getEditMinMaxVal(info,&min,&max,&val);
    char_t valS[20];
    _itoa(val,valS,10);
    char_t query[100];
    tsprintf(query,self->_(0,_l("Enter value in range from %i to %i")),min,max);
    if (!self->inputString(self->_(0,_l("Edit trackbar value")),query,valS,20)) {
        return false;
    }
    storeEditValue(info,min,max,valS);
    return true;
}
Exemplo n.º 29
0
int main_0041_fetch_max_bytes (int argc, char **argv) {
	const char *topic = test_mk_topic_name(__FUNCTION__, 1);
	const int partition = 0;
	const int msgcnt = 2*1000;
	const int MAX_BYTES = 100000;
	uint64_t testid;
	rd_kafka_conf_t *conf;
	rd_kafka_t *rk;
	rd_kafka_topic_t *rkt;

	test_conf_init(NULL, NULL, 60);
	
	testid = test_id_generate();
	rk = test_create_producer();
	rkt = test_create_producer_topic(rk, topic, NULL);

	test_produce_msgs(rk, rkt, testid, partition, 0, msgcnt/2, NULL, MAX_BYTES/10);
	test_produce_msgs(rk, rkt, testid, partition, msgcnt/2, msgcnt/2, NULL, MAX_BYTES*5);

	rd_kafka_topic_destroy(rkt);
	rd_kafka_destroy(rk);

	TEST_SAY("Creating consumer\n");
	test_conf_init(&conf, NULL, 0);

	test_conf_set(conf, "fetch.message.max.bytes", tsprintf("%d", MAX_BYTES));
	
	rk = test_create_consumer(NULL, NULL, conf, NULL);
	rkt = rd_kafka_topic_new(rk, topic, NULL);

	test_consumer_start("CONSUME", rkt, partition,
			    RD_KAFKA_OFFSET_BEGINNING);
	test_consume_msgs("CONSUME", rkt, testid, partition, TEST_NO_SEEK,
			  0, msgcnt, 1);
	test_consumer_stop("CONSUME", rkt, partition);

	rd_kafka_topic_destroy(rkt);
	rd_kafka_destroy(rk);

	return 0;
}
Exemplo n.º 30
0
const char_t* TinfoDecAudio::TinfoValueDecAudio::getVal0(bool &wasChange, bool &splitline)
{
    switch (item->type) {
        case IDFF_OSDtype_outSpeakersConfig:
            deciA->getOutSpeakersDescr(s, 512, true);
            wasChange = strcmp(s, olds) != 0;
            return s;
        case IDFF_OSDtype_audioSampleFormat: {
            int sf;
            const char_t *sampleFormat = SUCCEEDED(deciA->currentSampleFormat(NULL, NULL, &sf)) ? TsampleFormat::descriptionPCM(sf) : _l("unknown");
            ff_strncpy(s, sampleFormat, countof(s));
            wasChange = oldSampleFormat != sampleFormat;
            oldSampleFormat = sampleFormat;
            return s;
        }
        case IDFF_OSDtype_sampleFrequency: {
            unsigned int freq;
            if (FAILED(deciA->currentSampleFormat(NULL, &freq, NULL))) {
                freq = 0;
            }
            wasChange = oldfreq != freq;
            oldfreq = freq;
            return _itoa(freq, s, 10);
        }
        case IDFF_OSDtype_nchannels: {
            unsigned int nchannels;
            if (FAILED(deciA->currentSampleFormat(&nchannels, NULL, NULL))) {
                nchannels = 0;
            }
            wasChange = oldnchannels != nchannels;
            oldnchannels = nchannels;
            return _itoa(nchannels, s, 10);
        }
        case IDFF_OSDtype_audioJitter:
            tsprintf(s, _l("%5i ms"), deciA->getJitter());
            wasChange = true;
            return s;
        default:
            return TinfoValueDec::getVal0(wasChange, splitline);
    }
}