void Rect::setWidthHeight(float newWidth, float newHeight) { setZone(m_posX, m_posY, newWidth, newHeight); }
void Rect::setPosition(float newPosX, float newPosY) { setZone(newPosX, newPosY); }
void MinixFSZone::addZone(uint32 zone) { setZone(num_zones_, zone); }
//--------------------------------------------------------------------------- IPAddress::IPAddress( const String &inString, WORD inPort ) throw (IPAddress::Exceptions::ParseError) { clear(); String zone; { if (inString.isEmpty()) goto finally; // scope: try to parse as an IPv6 address first try { String::size_type openBracketPos = inString.find('['); String::size_type closeBracketPos = (openBracketPos != String::npos ? inString.find(']', openBracketPos+1) : String::npos); // this is illegal ZS_THROW_CUSTOM_MSG_IF( Exceptions::ParseError, ((String::npos != openBracketPos) || (String::npos != closeBracketPos)) && ((String::npos == openBracketPos) || (String::npos == closeBracketPos)), "IPv6 address missing matching [] during parse: " ) String ipv6; if (String::npos != openBracketPos) { String::size_type colonPos = inString.find(":", closeBracketPos+1); if (String::npos != colonPos) { ZS_THROW_CUSTOM_MSG_IF( Exceptions::ParseError, colonPos != closeBracketPos+1, "Colon \':\' was illegally placed in IPv6 address (should be in format [address]:port): " ) String port(inString.substr(colonPos+1)); port.trim(); inPort = (WORD)(Numeric<WORD>(port)); } ipv6 = inString.substr(openBracketPos+1, (closeBracketPos-(openBracketPos+1))); } else { ipv6 = inString; } ipv6.trim(); String::size_type posPercent = ipv6.rfind('%'); if (String::npos != posPercent) { zone = ipv6.substr(posPercent+1); ipv6 = ipv6.substr(0, posPercent); zone.trim(); ipv6.trim(); } // do a trial convert, done if succeeds if (internal::inet_pton6(ipv6, (unsigned char *)&mIPAddress)) goto next; ZS_THROW_CUSTOM_MSG_IF( Exceptions::ParseError, ((String::npos != openBracketPos) || (String::npos != closeBracketPos)), // could not be an IPv4 if contained brackets "Found illegal [] brackets around a non-IPv6 address <" + inString + ">: " ) } catch(const Numeric<WORD>::ValueOutOfRange &) { ZS_THROW_CUSTOM(Exceptions::ParseError, ("Failed to parse IP address: " + inString).c_str()) } // scope: try to parse as IPv4 try { // this has to be an IPv4 address String ipv4; String::size_type colonPos = inString.find(':'); if (String::npos != colonPos) { String port(inString.substr(colonPos+1)); port.trim(); inPort = (WORD)(Numeric<WORD>(port)); ipv4 = inString.substr(0, colonPos); ipv4.trim(); } else { ipv4 = inString; } ipv4.trim(); String::size_type posPercent = ipv4.rfind('%'); if (String::npos != posPercent) { zone = ipv4.substr(posPercent + 1); ipv4 = ipv4.substr(0, posPercent); zone.trim(); ipv4.trim(); } DWORD address = 0; if (internal::inet_pton4(ipv4, (BYTE *)&address)) { IPAddress temp(ntohl(address)); (*this) = temp; goto next; } } catch(const Numeric<WORD>::ValueOutOfRange &) { ZS_THROW_CUSTOM(Exceptions::ParseError, ("Failed to parse IP address: " + inString).c_str()) } // this was not an IPv6 or IPv4 address, conversion failed ZS_THROW_CUSTOM(Exceptions::ParseError, ("Failed to parse IP address: " + inString).c_str()) } next: { if (0 != inPort) mPort = htons(inPort); if (zone.hasData()) { setZone(zone); } } finally: { } }
void Bouclier::draw(SDL_Surface* screen, int x, int y, ZoneRect* z, int direction) { setZone(z); if (type == 2) { switch (direction) { case N : zone->getZone()->x--; zone->getZone()->y-=2; zone->getZone()->w+=3; zone->getZone()->h+=2; break; case S : zone->getZone()->x-=2; zone->getZone()->y-=2; zone->getZone()->w+=3; zone->getZone()->h+=2; x+=3; break; case O : case E : x+=6; zone->getZone()->y--; zone->getZone()->h+=2; break; } } if (type == 3) { switch (direction) { case N : zone->getZone()->x-=2; zone->getZone()->y-=4; zone->getZone()->w+=5; zone->getZone()->h+=5; break; case S : zone->getZone()->x-=3; zone->getZone()->y-=4; zone->getZone()->w+=5; zone->getZone()->h+=5; x+=5; break; case O : case E : x+=10; zone->getZone()->y--; zone->getZone()->h+=4; break; } } if (type == 10) { switch (direction) { case N : zone->getZone()->x--; zone->getZone()->w+=2; zone->getZone()->h++; break; case S : zone->getZone()->x--; zone->getZone()->y--; zone->getZone()->w+=2; zone->getZone()->h++; x+=2; break; case O : case E : x+=4; zone->getZone()->h++; break; } } SDL_Rect src; src.x = x; src.y = y; src.w = zone->getZone()->w; src.h = zone->getZone()->h; SDL_Rect dst; dst.x = zone->getZone()->x; dst.y = zone->getZone()->y; SDL_BlitSurface(image, &src, screen, &dst); }