Esempio n. 1
0
/**
 * Sets an LDM product-identifier from a GRIB message.
 *
 * Not Atomic,
 * Idempotent,
 * Thread-safe
 *
 * @param[out] ident      Product-identifier buffer.
 * @param[in]  identSize  Size of product-identifier buffer in bytes.
 * @param[in]  decoded    Decoded GRIB message.
 * @param[in]  wmoHead    WMO header associated with the GRIB message.
 * @retval     0          Success. \c *ident is set.
 * @retval     1          GRIB message has no data.
 * @retval     3          System error.
 */
static int setIdent(
    char* const            ident,
    const size_t           identSize,
    DecodedGrib2Msg* const decoded,
    const char* const      wmoHead)
{
    const size_t   numFields = g2d_getNumFields(decoded);
    int            status;

    if (0 == numFields) {
        log_add("GRIB message has no fields");
        status = 1;
    }
    else {
        StringBuf* const prods = strBuf_new(127); /* initially empty */

        if (NULL == prods) {
            log_add_syserr("Couldn't allocate string-buffer for products");
            log_flush_error();
            status = 3;
        }
        else {
            Gribmsg          gribMsg;
            Geminfo          gemInfo;
            int              modelId;

            status = appendParameterNames(prods, decoded, &gribMsg, &gemInfo);

            if (0 == status) {
                status = getModelId(decoded, &modelId);

                if (0 == status)
                    composeIdent(ident, identSize, decoded, &gribMsg, &gemInfo,
                            prods, wmoHead, modelId);
            }

            strBuf_free(prods);
        } /* "prods" allocated */
    } /* numFields > 0 */

    return status;
}
Esempio n. 2
0
Enemy::Enemy(GameScene& scene,
			 gr::real_t speed,
			 std::size_t id,
			 const Path& path,
			 const LayerDatas& datas,
			 Listener* listener)
:	_polygons(),
	_speed(speed),
	_id(id),
	_scene(scene),
	_pathPoint(path.getStart()),
	_listener(listener)
{
	ASSERT(_id != 0, "Unit requires non-zero model id.");

	for (unsigned short i = 0; i < datas.size(); ++i)
	{
		Polygon polygon(_scene,
						getModelId(_id, i),
						datas[i].type,
						datas[i].hp);

		AnimatedPolygon animatedPolygon
		(
			scene,
			std::move(polygon),
			NormalAnimator
			{
				1.0f / gr::real_t(1 + i), 
				(i % 2 == 0 ? HALF_PI : -HALF_PI)
			}
		);

		_polygons.push_back(std::move(animatedPolygon));
	}
}