Добавлен , не публикуется
В своей карте я сохраняю данные на хендл юнита каждые 0.03 секунды
set n = n + 1
call SaveReal(h,GetHandleId(u),n,GetUnitX(u))
Есть ли какой-то предел в хештаблице для числа n в моем случае, после которого все может поломаться и перестать корректно грузиться?
1
29
7 лет назад
1
integer - целое 32-битное число принимает значения от -2147483648 до 2147483647.
0
23
7 лет назад
0
Зачем такой тик создавать ?? Если что лучше создай массив с количеством чтобы можно подбирать от начало к концу чтобы круг вечно было не увеличивая обьема массива
0
4
7 лет назад
0
А чем именно массив лучше? Такое заполнение хещ таблицы лагодром вызовет? Щас тестил с 2 юнитами минут 20 и ничего небыло.
0
32
7 лет назад
0
Daniil18, массивы быстрее, да и обращение к ним проще, только 1 целое число о 0 до 8191.
Структуры как раз и удобнее и быстрее в таких местах.
0
4
7 лет назад
0
Ну, там какие нибудь тысячные доли секунд?
В случае "кругов" массивов мне там побольше возни с переменными нужно делать и перезаписывать их, все равно лучше с массивом? Из переменных только реальные и целочисленные. Думаю в моем случае вообще без разницы, просто в начале не вышло с массивыми, с хешем получилось, но щас я уже допер как опять с массивами сделать.
0
26
7 лет назад
0
а можно вопрос зачем?
0
4
7 лет назад
0
Делаю свою тупенькую систему заносов на льду, для этого мне нужно хранить последние 10 x\y координат юнита
0
16
7 лет назад
0
Daniil18, нужно хранить 10, а ты хранишь миллиарды?
0
30
7 лет назад
0
Vec3wc
interface Vec {
    public float x;
    public float y;
    public float z;

    public Vec   clone      ();
    public Vec   copy       (Vec   another);
    public Vec   plus       (Vec   another);
    public Vec   minus      (Vec   another);
    public Vec   mult       (float number);
    public Vec   div        (float number);
    public float dot        (Vec   another);
    public float distToSqr  (Vec   another);
    public float distTo     (Vec   another);
    public float angle      (Vec   edge);
    public Vec   reflect    (Vec   normal);
    public float radius     ();
    public Vec   normalize  ();
}

struct Vec3 extends Vec {
    // Constructors
    public static Vec3 create(float x, float y, float z) {
        Vec3 this = Vec3.allocate();
        this.x = x;
        this.y = y;
        this.z = z;
        return this;
    }

    public Vec clone() {
        return Vec3.create(this.x, this.y, this.z);
    }

    public Vec copy(Vec another) {
        this.x = another.x;
        this.y = another.y;
        this.z = another.z;
        return this;
    }

    // Basic math
    public Vec plus(Vec another) {
        this.x += another.x;
        this.y += another.y;
        this.z += another.z;
        return this;
    }

    public Vec minus(Vec another) {
        this.x += -another.x;
        this.y += -another.y;
        this.z += -another.z;
        return this;
    }

    public Vec mult(float number) {
        this.x *= number;
        this.y *= number;
        this.z *= number;
        return this;
    }

    public Vec div(float number) {
        return this.mult(1/number);
    }

    // Advanced math
    public static Vec3 cross(Vec edge1, Vec edge2) {
        return Vec3.create(edge1.y*edge2.z - edge1.z*edge2.y, edge1.z*edge2.x - edge1.x*edge2.z, edge1.x*edge2.y - edge1.y*edge2.x);
    }

    public float dot(Vec another) {
        return this.x*another.x + this.y*another.y + this.z*another.z;
    }

    public float distToSqr(Vec another) {
        return (this.x - another.x)*(this.x - another.x) + (this.y - another.y)*(this.y - another.y) + (this.z - another.z)*(this.z - another.z);
    }

    public float distTo(Vec another) {
        return SquareRoot(this.distToSqr(another));
    }

    public float angle(Vec edge) {
        return Acos(this.dot(edge)/this.radius()*edge.radius());
    }

    // Misc.
    public static Vec triangleNormal(Vec a, Vec b, Vec c) {
        Vec3 edge1 = b.clone().minus(a);
        Vec3 edge2 = c.clone().minus(a);
        Vec3 result = Vec3.cross(edge1, edge2).normalize();
        edge1.destroy();
        edge2.destroy();
        return result;
    }

    public Vec reflect(Vec normal) {
        float multipler = 2.0*this.dot(normal);
        this.minus(normal.mult(multipler));
        normal.div(multipler);
        return this;
    }

    public float radius() {
        return SquareRoot(this.dot(this));
    }

    public Vec normalize() {
        return this.div(this.radius());
    }
}

Небольшие знания векторной алгебры помогут сделать задуманное без костылей.
.z можно выпилить, само собой.
1
18
7 лет назад
Отредактирован Maniac_91
1
Daniil18, я вчера (а нет, уже сегодня) одну карту в блог скинул как раз с сохранением координат.
Глянь, может, пригодится: Петля времени.
Чтобы оставить комментарий, пожалуйста, войдите на сайт.