当前位置: 首页>>代码示例>>C++>>正文


C++ MapList::insert方法代码示例

本文整理汇总了C++中MapList::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ MapList::insert方法的具体用法?C++ MapList::insert怎么用?C++ MapList::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapList的用法示例。


在下文中一共展示了MapList::insert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnUserSexChanged

// Изменение иконки пользователя.
void OnUserSexChanged(BYTE *InBuffer) {
	String name;
	DWORD sex;

	try {
		//name
		GetStreamString(&InBuffer, &name);
		//ip
		GetStreamString(&InBuffer, NULL);
		//male
		GetStreamDword(&InBuffer, NULL);
		//new male
		GetStreamDword(&InBuffer, &sex);

		UpdateOnlineUserSex(name, sex);

        MapList params;
		params.insert(pair<String, String>("user", name));
		params.insert(pair<String, String>("sex", sex));

		String json_object = SetParametersObject(params);
		SendNotification("user_sex_changed", json_object, GetConnectionsRef(true));
	} catch (Exception *E) {
		throw(Format(e_user_sex_changed, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:27,代码来源:cf_events.cpp

示例2: setTextures

void DynamicMaterial::setTextures(MaterialEditor* src) {
    if(!m_material) return;
    if(m_stream) m_stream->build();

    // Textures
    m_material->setTexture("diffuseArray", src->getDiffuseArray());
    m_material->setTexture("normalArray", src->getNormalArray());
    if(m_stream) {
        m_stream->setTexture("diffuseArray", src->getDiffuseArray());
        m_stream->setTexture("normalArray", src->getNormalArray());
        printf("Textures set\n");
    }

    // Bind all the maps
    typedef std::set<const char*> MapList;
    MapList maps;
    for(size_t i=0; i<m_layers.size(); ++i) {
        if(m_layers[i]->map  && m_layers[i]->map[0])  maps.insert( m_layers[i]->map );
        if(m_layers[i]->map2 && m_layers[i]->map2[0]) maps.insert( m_layers[i]->map2 );
        update(i);
    }
    for(MapList::iterator i=maps.begin(); i!=maps.end(); ++i) {
        EditableTexture* map = src->getMap(*i);
        if(map) {
            m_material->setTexture(*i, map->getTexture());
            if(m_stream) {
                if(map->getTextureStream()) m_stream->addStream(*i, map->getTextureStream());
                else m_stream->setOverlayTexture(*i, map->getTexture());
            }
        }
    }
}
开发者ID:sgynn,项目名称:worldeditor,代码行数:32,代码来源:dynamicmaterial.cpp

示例3: OnUserChannelDisconnect

// Отключение от канала стороннего или виртуального пользователя.
void OnUserChannelDisconnect(BYTE *InBuffer) {
	String bot, channel, name;

	try {
		// virtual user.
		GetStreamString(&InBuffer, &bot);
		// channel.
		GetStreamString(&InBuffer, &channel);
		if (UserIsMonitoring(bot, channel)) {
            // name.
			GetStreamString(&InBuffer, &name);

			MapList params;
			params.insert(pair<String, String>("user", name));
			params.insert(pair<String, String>("channel", channel));

			String json_object = SetParametersObject(params);
			SendNotification("user_channel_disconnect", json_object, GetChannelConnections(channel));

			DeleteUserChannel(name, channel);

			// If channel watcher was disconnected, then find new watcher.
			if (name == bot) {
				ChangeChannelWatcher(channel);
			}
		}
	} catch (Exception *E) {
		throw(Format(e_user_channel_disconnect, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:31,代码来源:cf_events.cpp

示例4: OnUserChannelConnect

// Подключение к каналу стороннего пользователя.
void OnUserChannelConnect(BYTE *InBuffer) {
	String bot, name, channel, ip, query;
	DWORD male;

	try {
		//virtual user
		GetStreamString (&InBuffer, &bot);
		//channel
		GetStreamString(&InBuffer, &channel);

		// If this user is channel watcher.
		if (UserIsMonitoring(bot, channel)) {
			//name
			GetStreamString(&InBuffer, &name);
			//ip
			GetStreamString(&InBuffer, &ip);
			//male
			GetStreamDword(&InBuffer, &male);

			AddUserChannel(name, channel);

            MapList params;
			params.insert(pair<String, String>("user", name));
			params.insert(pair<String, String>("channel", channel));

			String json_object = SetParametersObject(params);
			SendNotification("user_channel_connect", json_object, GetChannelConnections(channel));
		}
	} catch (Exception *E) {
		throw(Format(e_user_channel_connect, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:33,代码来源:cf_events.cpp

示例5: OnUserDisconnect

// Выход из чата.
void OnUserDisconnect(BYTE *InBuffer) {
	String name;

	try {
		//name
		GetStreamString(&InBuffer, &name);

		RemoveUserFromChannels(name);

		// Проверяем, является ли пользователь виртуальным. Если да, то проверяем список отслеживаний каналов.
		LogicalConnections::iterator connection = FindConnectionByUser(name);
		if (ConnectionExists(connection)) {
			UnsetConnectionUser(connection);
		}

		RemoveOnlineUser(name);

		MapList params;
		params.insert(pair<String, String>("user", name));

		String json_object = SetParametersObject(params);
		SendNotification("user_disconnect", json_object, GetConnectionsRef(true));
	} catch (Exception *E) {
		throw(Format(e_user_disconnect, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:27,代码来源:cf_events.cpp

示例6: OnPublicChannelMessage

// Публикация в общий канал.
void OnPublicChannelMessage(BYTE *InBuffer) {
	String bot, name, channel, text;
	DWORD mode, male, image_length;

	try {
		//bot nick
		GetStreamString (&InBuffer, &bot);
		//nick
		GetStreamString(&InBuffer, &name);
		//ip
		GetStreamString(&InBuffer, NULL);
		//male
		GetStreamDword(&InBuffer, &male);
		//channel
		GetStreamString(&InBuffer, &channel);

		// Если виртуальный пользователь является пользователем, отслеживающим данный канал.
		if (UserIsMonitoring(bot, channel)) {
			//rezim
			GetStreamDword(&InBuffer, &mode);
			//text
			GetStreamString(&InBuffer, &text);

			GetStreamDword(&InBuffer, &image_length);

			MapList params;
			params.insert(pair<String, String>("sender", name));
			params.insert(pair<String, String>("channel", channel));
			params.insert(pair<String, String>("mode", mode));
			params.insert(pair<String, String>("message", text));

            if (image_length > 0) {
				String image_name = SaveData(InBuffer, image_length);
				if (!image_name.IsEmpty()) {
					params.insert(pair<String, String>("image", image_name));
				}
			}
			String json_object = SetParametersObject(params);
			SendNotification("public_mess", json_object, GetChannelConnections(channel));
	   	}
	} catch (Exception *E) {
		throw(Format(e_user_mess_recieve, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:45,代码来源:cf_events.cpp

示例7: OnVirtualUserChannelConnect

// Подключение к каналу виртуального пользователя.
void OnVirtualUserChannelConnect(BYTE *InBuffer) {
	String name, channel_name;

	try {
		// virtual user.
		GetStreamString (&InBuffer, &name);
		// channel.
		GetStreamString(&InBuffer, &channel_name);
		// topic.
		GetStreamString(&InBuffer, NULL);
		// greeting.
		GetStreamString(&InBuffer, NULL);

		LogicalConnections::iterator connection = FindConnectionByUser(name);
		OnlineUsersList::iterator user = GetConnectionUser(connection);
		ChannelsList::iterator channel = FindChannelByName(channel_name);
		StringList channel_users;
		if (!IsChannelMonitored(channel_name)) {
			AddChannelWatcher(name, channel_name);
			Channel channel_info = GetChannelInfo(channel_name);
			channel_users = GetChannelUsersList(name, channel_name);
			channel_info.online_users = channel_users.size();
			UpdateChannel(channel, GetChannelInfo(channel_name));
			for (unsigned int i = 0; i < channel_info.online_users; i++) {
				AddUserChannel(name, channel_name);
			}
		} else {
			AddUserChannel(name, channel_name);
			channel_users = GetChannelUsers(channel_name);
        }

		MapList params;
		params.insert(pair<String, String>("channel", channel_name));
		params.insert(pair<String, String>("topic", channel->topic));
		params.insert(pair<String, String>("greeting", channel->greeting));
		params.insert(pair<String, String>("users", "[" + implode(channel_users) + "]"));

		String json_object = SetParametersObject(params, true);
		SendNotification("virtual_user_channel_connect", json_object, connection, false);
	} catch (Exception *E) {
		throw(Format(e_virtual_user_channel_connect, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:44,代码来源:cf_events.cpp

示例8: OnUserConnect

// Вход в чат.
void OnUserConnect(BYTE *InBuffer) {
	String name, ip, query;
	DWORD male;

	try {
		//name
		GetStreamString(&InBuffer, &name);
		//ip
		GetStreamString(&InBuffer, &ip);
		//male
		GetStreamDword(&InBuffer, &male);

		// Get user from registred users list, add it's reference to online users and update user info.
		UsersList::iterator user = FindUserByName(name);
		CFUserInfo user_info = GetUserInfo(name);
		OnlineUsersList::iterator online_user = AddOnlineUser(user, user_info.state, user_info.client_version, user_info.process, user_info.window_activity, user_info.downtime);
		UpdateUser(user, user_info.computer_id, user_info.ip, user_info.male);

		// If user is in authorization queue.
		AuthQueueMap::iterator auth_queue_item = FindAuthQueueByUser(name);
		if (IsAuthQueueElement(auth_queue_item)) {
			LogicalConnections::iterator connection = GetAuthQueueConnection(auth_queue_item);
			SetConnectionUser(connection, online_user);
			SetAuthorizationStatus(connection, 9);
			DeleteAuthQueueItem(auth_queue_item);
		}

		MapList params;
		params.insert(pair<String, String>("name", name));
		params.insert(pair<String, String>("ip", ip));
		params.insert(pair<String, String>("sex", male));

		String json_object = SetParametersObject(params, true);
		SendNotification("user_connect", json_object, GetConnectionsRef(true));
	} catch (Exception *E) {
		throw(Format(e_user_connect, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:39,代码来源:cf_events.cpp

示例9: OnChannelTopicChanged

// Изменение темы.
void OnChannelTopicChanged(BYTE *InBuffer) {
	String bot, name, channel, topic;

	try {
		//bot_prop.name
		GetStreamString(&InBuffer, &bot);

		// Если виртуальный пользователь является пользователем, отслеживающим данный канал.
		if (UserIsMonitoring(bot, channel)) {
			//channel
			GetStreamString(&InBuffer, &channel);
			//name
			GetStreamString(&InBuffer, &name);
			//ip
			GetStreamString(&InBuffer, NULL);
			//male
			GetStreamDword(&InBuffer, NULL);
			//new theme
			GetStreamString(&InBuffer, &topic);

			int timestamp = time(NULL);

			UpdateChannelTopic(channel, topic, name, timestamp);

			MapList params;
			params.insert(pair<String, String>("channel", channel));
			params.insert(pair<String, String>("topic_editor", name));
			params.insert(pair<String, String>("topic", topic));
			params.insert(pair<String, String>("timestamp", timestamp));

			String json_object = SetParametersObject(params);
			SendNotification("channel_topic_changed", json_object, GetChannelConnections(channel));
		}
	} catch (Exception *E) {
		throw(Format(e_chnl_theme_changed, ARRAYOFCONST((E->Message))));
	}
}
开发者ID:PaulAnnekov,项目名称:commfort-webchat,代码行数:38,代码来源:cf_events.cpp

示例10: compile

bool DynamicMaterial::compile() {
    std::string source;

    // Inputs
    source +=
        "#version 130\n\n"
        "in vec3 worldNormal;\n"
        "in vec3 worldPos;\n\n"
        "uniform vec3 lightDirection;\n\n";

    // Samplers
    source +=
        "uniform sampler2DArray diffuseArray;\n"
        "uniform sampler2DArray normalArray;\n";

    // Maps
    typedef std::set<std::string> MapList;
    MapList maps;
    for(size_t i=0; i<m_layers.size(); ++i) {
        if(m_layers[i]->map  && m_layers[i]->map[0])  maps.insert( str(m_layers[i]->map) );
        if(m_layers[i]->map2 && m_layers[i]->map2[0]) maps.insert( str(m_layers[i]->map2) );
    }
    for(MapList::iterator i=maps.begin(); i!=maps.end(); ++i) source += "uniform sampler2D " + *i + "Map;\n";
    for(MapList::iterator i=maps.begin(); i!=maps.end(); ++i) source += "uniform vec4 " + *i + "Info;\n";
    source += "\n\n";

    // Variables
    for(size_t i=0; i<m_layers.size(); ++i) {
        std::string index = str(i);
        if(m_layers[i]->projection == PROJECTION_FLAT) source += "uniform vec2 scale" + index + ";\n";
        else source += "uniform vec3 scale" + index + ";\n";
        source += "uniform float opacity" + index + ";\n";
        if(m_layers[i]->type == LAYER_AUTO) source +=
                "uniform vec3 autoMin" + index + ";\n"
                "uniform vec3 autoMax" + index + ";\n"
                "uniform vec3 autoBlend" + index + ";\n";
    }

    source += "\n\n//Utility functions\n";

    // Functions
    source +=
        "vec4 sampleTriplanar(float map, vec3 coord, vec3 weights) {\n"
        "	vec4 c = vec4(coord.xyz, map);\n"
        "	return texture(diffuseArray, c.yzw)*weights.xxxx + texture(diffuseArray, c.zxw)*weights.yyyy + texture(diffuseArray, c.xyw)*weights.zzzz;\n"
        "}\n";

    source +=
        "vec4 sampleTriplanerNormal(float map, vec3 coord, vec3 normal, vec3 weights) {\n"
        "	vec4 c = vec4(coord.xyz, map);\n"
        "	vec4 nX = texture(normalArray, c.yzw);\n"
        "	vec4 nY = texture(normalArray, c.zxw);\n"
        "	vec4 nZ = texture(normalArray, c.xyw);\n"
        "	nX.xyz = nX.xyz * 2.0 - 1.0;\n"
        "	nY.xyz = nY.xyz * 2.0 - 1.0;\n"
        "	nZ.xyz = nZ.xyz * 2.0 - 1.0;\n"
        "	if(dot(nX.xyz, normal)<0.0) nX.x = -nX.x;\n"
        "	if(dot(nY.xyz, normal)<0.0) nY.y = -nY.y;\n"
        "	if(dot(nZ.xyz, normal)<0.0) nZ.z = -nZ.z;\n"
        "	vec3 result = normalize(nX.xyz*weights.xxx + nY.xyz*weights.yyy + nZ.xyz*weights.zzz);\n"
        "	return vec4(result, nX.w*weights.x + nY.w*weights.y + nZ.w*weights.z);\n"
        "}\n";

    source +=
        "float getAutoWeight(vec3 value, vec3 vmin, vec3 vmax, vec3 vblend) {\n"
//	"	vec3 ctr = (vmin + vmax) * 0.5;\n"
//	"	vec3 r = smoothstep(ctr - vmin, ctr - vmin + vblend, abs(value - ctr));\n"
        "	vec3 r = smoothstep(vmin-vblend, vmin, value) * smoothstep(vmax+vblend, vmax, value);\n"
        "	return r.x * r.y * r.z;\n"
        "}\n";

    source +=
        "vec4 sampleMap(sampler2D map, vec4 info, vec2 coord) {\n"
        "	coord = (coord - info.xy) * info.zw;\n"
        "	return texture(map, coord);\n"
        "}\n";

    source +=
        "vec4 sampleDiffuse(float map, vec2 coord) {\n"
        "	return texture(diffuseArray, vec3(coord, map));\n"
        "}\n";

    source +=
        "vec4 sampleNormal(float map, vec2 coord) {\n"
        "	vec4 n = texture(diffuseArray, vec3(coord, map));\n"
        "	return vec4(n.xyz * 2.0 - 1.0, n.w);\n"
        "}\n\n\n";

    // Main function
    source +=
        "// Main shader function\n"
        "void main() {\n"
        "	vec4 diffuse = vec4(1,1,1,1);\n"
        "	vec4 normal = vec4(0,1,0,0);\n"
        "	float gloss = 0.0;\n"
        "	float height;\n"
        "	float weight;\n"
        "	vec4 diff, norm;\n"
        "	vec3 triplanar = max( (abs(worldNormal) - 0.2) * 0.7, 0.0);\n"
        "	triplanar /= dot(triplanar, vec3(1,1,1));\n"
//.........这里部分代码省略.........
开发者ID:sgynn,项目名称:worldeditor,代码行数:101,代码来源:dynamicmaterial.cpp


注:本文中的MapList::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。