/** ** Notify player about a problem. ** ** @param type Problem type ** @param x Map X tile position ** @param y Map Y tile position ** @param fmt Message format ** @param ... Message varargs ** ** @note The parameter type, isn't yet used. ** @todo FIXME: We must also notfiy allied players. */ void CPlayer::Notify(int type, int x, int y, const char *fmt, ...) const { char temp[128]; va_list va; // Notify me, and my TEAM members if (this != ThisPlayer && !IsTeamed(ThisPlayer)) { return; } va_start(va, fmt); temp[sizeof(temp) - 1] = '\0'; vsnprintf(temp, sizeof(temp) - 1, fmt, va); va_end(va); if (x != -1) { UI.Minimap.AddEvent(x, y); } if (this == ThisPlayer) { SetMessageEvent(x, y, "%s", temp); } else { SetMessageEvent(x, y, "(%s): %s", Name.c_str(), temp); } }
/** ** Notify player about a problem. ** ** @param type Problem type ** @param pos Map tile position ** @param fmt Message format ** @param ... Message varargs ** ** @todo FIXME: We must also notfiy allied players. */ void CPlayer::Notify(int type, const Vec2i &pos, const char *fmt, ...) const { Assert(Map.Info.IsPointOnMap(pos)); char temp[128]; Uint32 color; va_list va; // Notify me, and my TEAM members if (this != ThisPlayer && !IsTeamed(*ThisPlayer)) { return; } va_start(va, fmt); temp[sizeof(temp) - 1] = '\0'; vsnprintf(temp, sizeof(temp) - 1, fmt, va); va_end(va); switch (type) { case NotifyRed: color = ColorRed; break; case NotifyYellow: color = ColorYellow; break; case NotifyGreen: color = ColorGreen; break; default: color = ColorWhite; } UI.Minimap.AddEvent(pos, color); if (this == ThisPlayer) { SetMessageEvent(pos, "%s", temp); } else { SetMessageEvent(pos, "(%s): %s", Name.c_str(), temp); } }
/** ** Notify player about a problem. ** ** @param type Problem type ** @param pos Map tile position ** @param fmt Message format ** @param ... Message varargs ** ** @todo FIXME: We must also notfiy allied players. */ void CPlayer::Notify(const char *fmt, ...) const { // Notify me, and my TEAM members if (this != ThisPlayer && !IsTeamed(*ThisPlayer)) { return; } char temp[128]; va_list va; va_start(va, fmt); temp[sizeof(temp) - 1] = '\0'; vsnprintf(temp, sizeof(temp) - 1, fmt, va); va_end(va); if (this == ThisPlayer) { SetMessage("%s", temp); } else { SetMessage("(%s): %s", Name.c_str(), temp); } }
/** ** Check if the unit is teamed */ bool CPlayer::IsTeamed(const CUnit &unit) const { return IsTeamed(*unit.Player); }
/** ** Check if the unit is teamed */ bool CPlayer::IsTeamed(const CUnit *x) const { return IsTeamed(x->Player); }